
obj/user/testpiperace:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 ef 01 00 00       	call   800220 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <umain>:
#include <inc/lib.h>

void
umain(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	56                   	push   %esi
  800038:	53                   	push   %ebx
  800039:	83 ec 20             	sub    $0x20,%esp
	int p[2], r, pid, i, max;
	void *va;
	struct Fd *fd;
	volatile struct Env *kid;

	cprintf("testing for dup race...\n");
  80003c:	c7 04 24 60 2e 80 00 	movl   $0x802e60,(%esp)
  800043:	e8 09 03 00 00       	call   800351 <cprintf>
	if ((r = pipe(p)) < 0)
  800048:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80004b:	89 04 24             	mov    %eax,(%esp)
  80004e:	e8 b6 27 00 00       	call   802809 <pipe>
  800053:	85 c0                	test   %eax,%eax
  800055:	79 20                	jns    800077 <umain+0x43>
		panic("pipe: %e", r);
  800057:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80005b:	c7 44 24 08 79 2e 80 	movl   $0x802e79,0x8(%esp)
  800062:	00 
  800063:	c7 44 24 04 0d 00 00 	movl   $0xd,0x4(%esp)
  80006a:	00 
  80006b:	c7 04 24 82 2e 80 00 	movl   $0x802e82,(%esp)
  800072:	e8 15 02 00 00       	call   80028c <_panic>
	max = 200;
	if ((r = fork()) < 0)
  800077:	e8 46 12 00 00       	call   8012c2 <fork>
  80007c:	89 c6                	mov    %eax,%esi
  80007e:	85 c0                	test   %eax,%eax
  800080:	79 20                	jns    8000a2 <umain+0x6e>
		panic("fork: %e", r);
  800082:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800086:	c7 44 24 08 96 2e 80 	movl   $0x802e96,0x8(%esp)
  80008d:	00 
  80008e:	c7 44 24 04 10 00 00 	movl   $0x10,0x4(%esp)
  800095:	00 
  800096:	c7 04 24 82 2e 80 00 	movl   $0x802e82,(%esp)
  80009d:	e8 ea 01 00 00       	call   80028c <_panic>
	if (r == 0) {
  8000a2:	85 c0                	test   %eax,%eax
  8000a4:	75 5c                	jne    800102 <umain+0xce>
		close(p[1]);
  8000a6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8000a9:	89 04 24             	mov    %eax,(%esp)
  8000ac:	e8 7b 1b 00 00       	call   801c2c <close>
  8000b1:	bb 00 00 00 00       	mov    $0x0,%ebx
		// If a clock interrupt catches dup between mapping the
		// fd and mapping the pipe structure, we'll have the same
		// ref counts, still a no-no.
		//
		for (i=0; i<max; i++) {
			if(pipeisclosed(p[0])){
  8000b6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8000b9:	89 04 24             	mov    %eax,(%esp)
  8000bc:	e8 15 27 00 00       	call   8027d6 <pipeisclosed>
  8000c1:	85 c0                	test   %eax,%eax
  8000c3:	74 11                	je     8000d6 <umain+0xa2>
				cprintf("RACE: pipe appears closed\n");
  8000c5:	c7 04 24 9f 2e 80 00 	movl   $0x802e9f,(%esp)
  8000cc:	e8 80 02 00 00       	call   800351 <cprintf>
				exit();
  8000d1:	e8 9a 01 00 00       	call   800270 <exit>
			}
			sys_yield();
  8000d6:	e8 fa 10 00 00       	call   8011d5 <sys_yield>
		//
		// If a clock interrupt catches dup between mapping the
		// fd and mapping the pipe structure, we'll have the same
		// ref counts, still a no-no.
		//
		for (i=0; i<max; i++) {
  8000db:	83 c3 01             	add    $0x1,%ebx
  8000de:	81 fb c8 00 00 00    	cmp    $0xc8,%ebx
  8000e4:	75 d0                	jne    8000b6 <umain+0x82>
				exit();
			}
			sys_yield();
		}
		// do something to be not runnable besides exiting
		ipc_recv(0,0,0);
  8000e6:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8000ed:	00 
  8000ee:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8000f5:	00 
  8000f6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8000fd:	e8 10 16 00 00       	call   801712 <ipc_recv>
	}
	pid = r;
	cprintf("pid is %d\n", pid);
  800102:	89 74 24 04          	mov    %esi,0x4(%esp)
  800106:	c7 04 24 ba 2e 80 00 	movl   $0x802eba,(%esp)
  80010d:	e8 3f 02 00 00       	call   800351 <cprintf>
	va = 0;
	kid = &envs[ENVX(pid)];
  800112:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  800118:	6b f6 7c             	imul   $0x7c,%esi,%esi
	cprintf("kid is %d\n", kid-envs);
  80011b:	8d 9e 00 00 c0 ee    	lea    -0x11400000(%esi),%ebx
  800121:	c1 ee 02             	shr    $0x2,%esi
  800124:	69 f6 df 7b ef bd    	imul   $0xbdef7bdf,%esi,%esi
  80012a:	89 74 24 04          	mov    %esi,0x4(%esp)
  80012e:	c7 04 24 c5 2e 80 00 	movl   $0x802ec5,(%esp)
  800135:	e8 17 02 00 00       	call   800351 <cprintf>
	dup(p[0], 10);
  80013a:	c7 44 24 04 0a 00 00 	movl   $0xa,0x4(%esp)
  800141:	00 
  800142:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800145:	89 04 24             	mov    %eax,(%esp)
  800148:	e8 7e 1b 00 00       	call   801ccb <dup>
	while (kid->env_status == ENV_RUNNABLE)
  80014d:	8b 43 54             	mov    0x54(%ebx),%eax
  800150:	83 f8 01             	cmp    $0x1,%eax
  800153:	75 1b                	jne    800170 <umain+0x13c>
		dup(p[0], 10);
  800155:	c7 44 24 04 0a 00 00 	movl   $0xa,0x4(%esp)
  80015c:	00 
  80015d:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800160:	89 04 24             	mov    %eax,(%esp)
  800163:	e8 63 1b 00 00       	call   801ccb <dup>
	cprintf("pid is %d\n", pid);
	va = 0;
	kid = &envs[ENVX(pid)];
	cprintf("kid is %d\n", kid-envs);
	dup(p[0], 10);
	while (kid->env_status == ENV_RUNNABLE)
  800168:	8b 43 54             	mov    0x54(%ebx),%eax
  80016b:	83 f8 01             	cmp    $0x1,%eax
  80016e:	74 e5                	je     800155 <umain+0x121>
		dup(p[0], 10);

	cprintf("child done with loop\n");
  800170:	c7 04 24 d0 2e 80 00 	movl   $0x802ed0,(%esp)
  800177:	e8 d5 01 00 00       	call   800351 <cprintf>
	if (pipeisclosed(p[0]))
  80017c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80017f:	89 04 24             	mov    %eax,(%esp)
  800182:	e8 4f 26 00 00       	call   8027d6 <pipeisclosed>
  800187:	85 c0                	test   %eax,%eax
  800189:	74 1c                	je     8001a7 <umain+0x173>
		panic("somehow the other end of p[0] got closed!");
  80018b:	c7 44 24 08 2c 2f 80 	movl   $0x802f2c,0x8(%esp)
  800192:	00 
  800193:	c7 44 24 04 3a 00 00 	movl   $0x3a,0x4(%esp)
  80019a:	00 
  80019b:	c7 04 24 82 2e 80 00 	movl   $0x802e82,(%esp)
  8001a2:	e8 e5 00 00 00       	call   80028c <_panic>
	if ((r = fd_lookup(p[0], &fd)) < 0)
  8001a7:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8001aa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001ae:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8001b1:	89 04 24             	mov    %eax,(%esp)
  8001b4:	e8 54 16 00 00       	call   80180d <fd_lookup>
  8001b9:	85 c0                	test   %eax,%eax
  8001bb:	79 20                	jns    8001dd <umain+0x1a9>
		panic("cannot look up p[0]: %e", r);
  8001bd:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001c1:	c7 44 24 08 e6 2e 80 	movl   $0x802ee6,0x8(%esp)
  8001c8:	00 
  8001c9:	c7 44 24 04 3c 00 00 	movl   $0x3c,0x4(%esp)
  8001d0:	00 
  8001d1:	c7 04 24 82 2e 80 00 	movl   $0x802e82,(%esp)
  8001d8:	e8 af 00 00 00       	call   80028c <_panic>
	va = fd2data(fd);
  8001dd:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8001e0:	89 04 24             	mov    %eax,(%esp)
  8001e3:	e8 98 15 00 00       	call   801780 <fd2data>
	if (pageref(va) != 3+1)
  8001e8:	89 04 24             	mov    %eax,(%esp)
  8001eb:	e8 98 1e 00 00       	call   802088 <pageref>
  8001f0:	83 f8 04             	cmp    $0x4,%eax
  8001f3:	74 0e                	je     800203 <umain+0x1cf>
		cprintf("\nchild detected race\n");
  8001f5:	c7 04 24 fe 2e 80 00 	movl   $0x802efe,(%esp)
  8001fc:	e8 50 01 00 00       	call   800351 <cprintf>
  800201:	eb 14                	jmp    800217 <umain+0x1e3>
	else
		cprintf("\nrace didn't happen\n", max);
  800203:	c7 44 24 04 c8 00 00 	movl   $0xc8,0x4(%esp)
  80020a:	00 
  80020b:	c7 04 24 14 2f 80 00 	movl   $0x802f14,(%esp)
  800212:	e8 3a 01 00 00       	call   800351 <cprintf>
}
  800217:	83 c4 20             	add    $0x20,%esp
  80021a:	5b                   	pop    %ebx
  80021b:	5e                   	pop    %esi
  80021c:	5d                   	pop    %ebp
  80021d:	c3                   	ret    
	...

00800220 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800220:	55                   	push   %ebp
  800221:	89 e5                	mov    %esp,%ebp
  800223:	83 ec 18             	sub    $0x18,%esp
  800226:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800229:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80022c:	8b 75 08             	mov    0x8(%ebp),%esi
  80022f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800232:	e8 d2 0f 00 00       	call   801209 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800237:	25 ff 03 00 00       	and    $0x3ff,%eax
  80023c:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80023f:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800244:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800249:	85 f6                	test   %esi,%esi
  80024b:	7e 07                	jle    800254 <libmain+0x34>
		binaryname = argv[0];
  80024d:	8b 03                	mov    (%ebx),%eax
  80024f:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800254:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800258:	89 34 24             	mov    %esi,(%esp)
  80025b:	e8 d4 fd ff ff       	call   800034 <umain>

	// exit gracefully
	exit();
  800260:	e8 0b 00 00 00       	call   800270 <exit>
}
  800265:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800268:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80026b:	89 ec                	mov    %ebp,%esp
  80026d:	5d                   	pop    %ebp
  80026e:	c3                   	ret    
	...

00800270 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800270:	55                   	push   %ebp
  800271:	89 e5                	mov    %esp,%ebp
  800273:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800276:	e8 2e 1a 00 00       	call   801ca9 <close_all>
	sys_env_destroy(0);
  80027b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800282:	e8 b6 0f 00 00       	call   80123d <sys_env_destroy>
}
  800287:	c9                   	leave  
  800288:	c3                   	ret    
  800289:	00 00                	add    %al,(%eax)
	...

0080028c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80028c:	55                   	push   %ebp
  80028d:	89 e5                	mov    %esp,%ebp
  80028f:	53                   	push   %ebx
  800290:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800293:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800296:	a1 78 70 80 00       	mov    0x807078,%eax
  80029b:	85 c0                	test   %eax,%eax
  80029d:	74 10                	je     8002af <_panic+0x23>
		cprintf("%s: ", argv0);
  80029f:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002a3:	c7 04 24 6d 2f 80 00 	movl   $0x802f6d,(%esp)
  8002aa:	e8 a2 00 00 00       	call   800351 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8002af:	8b 45 0c             	mov    0xc(%ebp),%eax
  8002b2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002b6:	8b 45 08             	mov    0x8(%ebp),%eax
  8002b9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002bd:	a1 00 70 80 00       	mov    0x807000,%eax
  8002c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002c6:	c7 04 24 72 2f 80 00 	movl   $0x802f72,(%esp)
  8002cd:	e8 7f 00 00 00       	call   800351 <cprintf>
	vcprintf(fmt, ap);
  8002d2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8002d6:	8b 45 10             	mov    0x10(%ebp),%eax
  8002d9:	89 04 24             	mov    %eax,(%esp)
  8002dc:	e8 0f 00 00 00       	call   8002f0 <vcprintf>
	cprintf("\n");
  8002e1:	c7 04 24 77 2e 80 00 	movl   $0x802e77,(%esp)
  8002e8:	e8 64 00 00 00       	call   800351 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8002ed:	cc                   	int3   
  8002ee:	eb fd                	jmp    8002ed <_panic+0x61>

008002f0 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8002f0:	55                   	push   %ebp
  8002f1:	89 e5                	mov    %esp,%ebp
  8002f3:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8002f9:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800300:	00 00 00 
	b.cnt = 0;
  800303:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80030a:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  80030d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800310:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800314:	8b 45 08             	mov    0x8(%ebp),%eax
  800317:	89 44 24 08          	mov    %eax,0x8(%esp)
  80031b:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800321:	89 44 24 04          	mov    %eax,0x4(%esp)
  800325:	c7 04 24 6b 03 80 00 	movl   $0x80036b,(%esp)
  80032c:	e8 cc 01 00 00       	call   8004fd <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800331:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800337:	89 44 24 04          	mov    %eax,0x4(%esp)
  80033b:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800341:	89 04 24             	mov    %eax,(%esp)
  800344:	e8 c7 0a 00 00       	call   800e10 <sys_cputs>

	return b.cnt;
}
  800349:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80034f:	c9                   	leave  
  800350:	c3                   	ret    

00800351 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800351:	55                   	push   %ebp
  800352:	89 e5                	mov    %esp,%ebp
  800354:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800357:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80035a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80035e:	8b 45 08             	mov    0x8(%ebp),%eax
  800361:	89 04 24             	mov    %eax,(%esp)
  800364:	e8 87 ff ff ff       	call   8002f0 <vcprintf>
	va_end(ap);

	return cnt;
}
  800369:	c9                   	leave  
  80036a:	c3                   	ret    

0080036b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80036b:	55                   	push   %ebp
  80036c:	89 e5                	mov    %esp,%ebp
  80036e:	53                   	push   %ebx
  80036f:	83 ec 14             	sub    $0x14,%esp
  800372:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800375:	8b 03                	mov    (%ebx),%eax
  800377:	8b 55 08             	mov    0x8(%ebp),%edx
  80037a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80037e:	83 c0 01             	add    $0x1,%eax
  800381:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800383:	3d ff 00 00 00       	cmp    $0xff,%eax
  800388:	75 19                	jne    8003a3 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80038a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800391:	00 
  800392:	8d 43 08             	lea    0x8(%ebx),%eax
  800395:	89 04 24             	mov    %eax,(%esp)
  800398:	e8 73 0a 00 00       	call   800e10 <sys_cputs>
		b->idx = 0;
  80039d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  8003a3:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  8003a7:	83 c4 14             	add    $0x14,%esp
  8003aa:	5b                   	pop    %ebx
  8003ab:	5d                   	pop    %ebp
  8003ac:	c3                   	ret    
  8003ad:	00 00                	add    %al,(%eax)
	...

008003b0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8003b0:	55                   	push   %ebp
  8003b1:	89 e5                	mov    %esp,%ebp
  8003b3:	57                   	push   %edi
  8003b4:	56                   	push   %esi
  8003b5:	53                   	push   %ebx
  8003b6:	83 ec 4c             	sub    $0x4c,%esp
  8003b9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8003bc:	89 d6                	mov    %edx,%esi
  8003be:	8b 45 08             	mov    0x8(%ebp),%eax
  8003c1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8003c4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8003c7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  8003ca:	8b 45 10             	mov    0x10(%ebp),%eax
  8003cd:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8003d0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8003d3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8003d6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8003db:	39 d1                	cmp    %edx,%ecx
  8003dd:	72 15                	jb     8003f4 <printnum+0x44>
  8003df:	77 07                	ja     8003e8 <printnum+0x38>
  8003e1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8003e4:	39 d0                	cmp    %edx,%eax
  8003e6:	76 0c                	jbe    8003f4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8003e8:	83 eb 01             	sub    $0x1,%ebx
  8003eb:	85 db                	test   %ebx,%ebx
  8003ed:	8d 76 00             	lea    0x0(%esi),%esi
  8003f0:	7f 61                	jg     800453 <printnum+0xa3>
  8003f2:	eb 70                	jmp    800464 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8003f4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8003f8:	83 eb 01             	sub    $0x1,%ebx
  8003fb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003ff:	89 44 24 08          	mov    %eax,0x8(%esp)
  800403:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800407:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80040b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80040e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800411:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800414:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800418:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80041f:	00 
  800420:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800423:	89 04 24             	mov    %eax,(%esp)
  800426:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800429:	89 54 24 04          	mov    %edx,0x4(%esp)
  80042d:	e8 ae 27 00 00       	call   802be0 <__udivdi3>
  800432:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800435:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800438:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80043c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800440:	89 04 24             	mov    %eax,(%esp)
  800443:	89 54 24 04          	mov    %edx,0x4(%esp)
  800447:	89 f2                	mov    %esi,%edx
  800449:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80044c:	e8 5f ff ff ff       	call   8003b0 <printnum>
  800451:	eb 11                	jmp    800464 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800453:	89 74 24 04          	mov    %esi,0x4(%esp)
  800457:	89 3c 24             	mov    %edi,(%esp)
  80045a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80045d:	83 eb 01             	sub    $0x1,%ebx
  800460:	85 db                	test   %ebx,%ebx
  800462:	7f ef                	jg     800453 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800464:	89 74 24 04          	mov    %esi,0x4(%esp)
  800468:	8b 74 24 04          	mov    0x4(%esp),%esi
  80046c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80046f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800473:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80047a:	00 
  80047b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80047e:	89 14 24             	mov    %edx,(%esp)
  800481:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800484:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800488:	e8 83 28 00 00       	call   802d10 <__umoddi3>
  80048d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800491:	0f be 80 8e 2f 80 00 	movsbl 0x802f8e(%eax),%eax
  800498:	89 04 24             	mov    %eax,(%esp)
  80049b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80049e:	83 c4 4c             	add    $0x4c,%esp
  8004a1:	5b                   	pop    %ebx
  8004a2:	5e                   	pop    %esi
  8004a3:	5f                   	pop    %edi
  8004a4:	5d                   	pop    %ebp
  8004a5:	c3                   	ret    

008004a6 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  8004a6:	55                   	push   %ebp
  8004a7:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  8004a9:	83 fa 01             	cmp    $0x1,%edx
  8004ac:	7e 0e                	jle    8004bc <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  8004ae:	8b 10                	mov    (%eax),%edx
  8004b0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8004b3:	89 08                	mov    %ecx,(%eax)
  8004b5:	8b 02                	mov    (%edx),%eax
  8004b7:	8b 52 04             	mov    0x4(%edx),%edx
  8004ba:	eb 22                	jmp    8004de <getuint+0x38>
	else if (lflag)
  8004bc:	85 d2                	test   %edx,%edx
  8004be:	74 10                	je     8004d0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8004c0:	8b 10                	mov    (%eax),%edx
  8004c2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8004c5:	89 08                	mov    %ecx,(%eax)
  8004c7:	8b 02                	mov    (%edx),%eax
  8004c9:	ba 00 00 00 00       	mov    $0x0,%edx
  8004ce:	eb 0e                	jmp    8004de <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8004d0:	8b 10                	mov    (%eax),%edx
  8004d2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8004d5:	89 08                	mov    %ecx,(%eax)
  8004d7:	8b 02                	mov    (%edx),%eax
  8004d9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8004de:	5d                   	pop    %ebp
  8004df:	c3                   	ret    

008004e0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8004e0:	55                   	push   %ebp
  8004e1:	89 e5                	mov    %esp,%ebp
  8004e3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8004e6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8004ea:	8b 10                	mov    (%eax),%edx
  8004ec:	3b 50 04             	cmp    0x4(%eax),%edx
  8004ef:	73 0a                	jae    8004fb <sprintputch+0x1b>
		*b->buf++ = ch;
  8004f1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8004f4:	88 0a                	mov    %cl,(%edx)
  8004f6:	83 c2 01             	add    $0x1,%edx
  8004f9:	89 10                	mov    %edx,(%eax)
}
  8004fb:	5d                   	pop    %ebp
  8004fc:	c3                   	ret    

008004fd <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8004fd:	55                   	push   %ebp
  8004fe:	89 e5                	mov    %esp,%ebp
  800500:	57                   	push   %edi
  800501:	56                   	push   %esi
  800502:	53                   	push   %ebx
  800503:	83 ec 5c             	sub    $0x5c,%esp
  800506:	8b 7d 08             	mov    0x8(%ebp),%edi
  800509:	8b 75 0c             	mov    0xc(%ebp),%esi
  80050c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80050f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800516:	eb 11                	jmp    800529 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800518:	85 c0                	test   %eax,%eax
  80051a:	0f 84 f9 03 00 00    	je     800919 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800520:	89 74 24 04          	mov    %esi,0x4(%esp)
  800524:	89 04 24             	mov    %eax,(%esp)
  800527:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800529:	0f b6 03             	movzbl (%ebx),%eax
  80052c:	83 c3 01             	add    $0x1,%ebx
  80052f:	83 f8 25             	cmp    $0x25,%eax
  800532:	75 e4                	jne    800518 <vprintfmt+0x1b>
  800534:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800538:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80053f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800546:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80054d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800552:	eb 06                	jmp    80055a <vprintfmt+0x5d>
  800554:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800558:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80055a:	0f b6 13             	movzbl (%ebx),%edx
  80055d:	0f b6 c2             	movzbl %dl,%eax
  800560:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800563:	8d 43 01             	lea    0x1(%ebx),%eax
  800566:	83 ea 23             	sub    $0x23,%edx
  800569:	80 fa 55             	cmp    $0x55,%dl
  80056c:	0f 87 8a 03 00 00    	ja     8008fc <vprintfmt+0x3ff>
  800572:	0f b6 d2             	movzbl %dl,%edx
  800575:	ff 24 95 e0 30 80 00 	jmp    *0x8030e0(,%edx,4)
  80057c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800580:	eb d6                	jmp    800558 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800582:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800585:	83 ea 30             	sub    $0x30,%edx
  800588:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80058b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80058e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800591:	83 fb 09             	cmp    $0x9,%ebx
  800594:	77 54                	ja     8005ea <vprintfmt+0xed>
  800596:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800599:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80059c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80059f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  8005a2:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  8005a6:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8005a9:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8005ac:	83 fb 09             	cmp    $0x9,%ebx
  8005af:	76 eb                	jbe    80059c <vprintfmt+0x9f>
  8005b1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8005b4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8005b7:	eb 31                	jmp    8005ea <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8005b9:	8b 55 14             	mov    0x14(%ebp),%edx
  8005bc:	8d 5a 04             	lea    0x4(%edx),%ebx
  8005bf:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8005c2:	8b 12                	mov    (%edx),%edx
  8005c4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8005c7:	eb 21                	jmp    8005ea <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8005c9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8005cd:	ba 00 00 00 00       	mov    $0x0,%edx
  8005d2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8005d6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8005d9:	e9 7a ff ff ff       	jmp    800558 <vprintfmt+0x5b>
  8005de:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8005e5:	e9 6e ff ff ff       	jmp    800558 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8005ea:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8005ee:	0f 89 64 ff ff ff    	jns    800558 <vprintfmt+0x5b>
  8005f4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8005f7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8005fa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8005fd:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800600:	e9 53 ff ff ff       	jmp    800558 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800605:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800608:	e9 4b ff ff ff       	jmp    800558 <vprintfmt+0x5b>
  80060d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800610:	8b 45 14             	mov    0x14(%ebp),%eax
  800613:	8d 50 04             	lea    0x4(%eax),%edx
  800616:	89 55 14             	mov    %edx,0x14(%ebp)
  800619:	89 74 24 04          	mov    %esi,0x4(%esp)
  80061d:	8b 00                	mov    (%eax),%eax
  80061f:	89 04 24             	mov    %eax,(%esp)
  800622:	ff d7                	call   *%edi
  800624:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800627:	e9 fd fe ff ff       	jmp    800529 <vprintfmt+0x2c>
  80062c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80062f:	8b 45 14             	mov    0x14(%ebp),%eax
  800632:	8d 50 04             	lea    0x4(%eax),%edx
  800635:	89 55 14             	mov    %edx,0x14(%ebp)
  800638:	8b 00                	mov    (%eax),%eax
  80063a:	89 c2                	mov    %eax,%edx
  80063c:	c1 fa 1f             	sar    $0x1f,%edx
  80063f:	31 d0                	xor    %edx,%eax
  800641:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800643:	83 f8 12             	cmp    $0x12,%eax
  800646:	7f 0b                	jg     800653 <vprintfmt+0x156>
  800648:	8b 14 85 40 32 80 00 	mov    0x803240(,%eax,4),%edx
  80064f:	85 d2                	test   %edx,%edx
  800651:	75 20                	jne    800673 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800653:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800657:	c7 44 24 08 9f 2f 80 	movl   $0x802f9f,0x8(%esp)
  80065e:	00 
  80065f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800663:	89 3c 24             	mov    %edi,(%esp)
  800666:	e8 36 03 00 00       	call   8009a1 <printfmt>
  80066b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80066e:	e9 b6 fe ff ff       	jmp    800529 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800673:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800677:	c7 44 24 08 82 35 80 	movl   $0x803582,0x8(%esp)
  80067e:	00 
  80067f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800683:	89 3c 24             	mov    %edi,(%esp)
  800686:	e8 16 03 00 00       	call   8009a1 <printfmt>
  80068b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80068e:	e9 96 fe ff ff       	jmp    800529 <vprintfmt+0x2c>
  800693:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800696:	89 c3                	mov    %eax,%ebx
  800698:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80069b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80069e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  8006a1:	8b 45 14             	mov    0x14(%ebp),%eax
  8006a4:	8d 50 04             	lea    0x4(%eax),%edx
  8006a7:	89 55 14             	mov    %edx,0x14(%ebp)
  8006aa:	8b 00                	mov    (%eax),%eax
  8006ac:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8006af:	85 c0                	test   %eax,%eax
  8006b1:	b8 a8 2f 80 00       	mov    $0x802fa8,%eax
  8006b6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  8006ba:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  8006bd:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  8006c1:	7e 06                	jle    8006c9 <vprintfmt+0x1cc>
  8006c3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  8006c7:	75 13                	jne    8006dc <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006c9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8006cc:	0f be 02             	movsbl (%edx),%eax
  8006cf:	85 c0                	test   %eax,%eax
  8006d1:	0f 85 9b 00 00 00    	jne    800772 <vprintfmt+0x275>
  8006d7:	e9 88 00 00 00       	jmp    800764 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8006dc:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8006e0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8006e3:	89 0c 24             	mov    %ecx,(%esp)
  8006e6:	e8 00 03 00 00       	call   8009eb <strnlen>
  8006eb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8006ee:	29 c2                	sub    %eax,%edx
  8006f0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006f3:	85 d2                	test   %edx,%edx
  8006f5:	7e d2                	jle    8006c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8006f7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8006fb:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8006fe:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800701:	89 d3                	mov    %edx,%ebx
  800703:	89 74 24 04          	mov    %esi,0x4(%esp)
  800707:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80070a:	89 04 24             	mov    %eax,(%esp)
  80070d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80070f:	83 eb 01             	sub    $0x1,%ebx
  800712:	85 db                	test   %ebx,%ebx
  800714:	7f ed                	jg     800703 <vprintfmt+0x206>
  800716:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800719:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800720:	eb a7                	jmp    8006c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800722:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800726:	74 1a                	je     800742 <vprintfmt+0x245>
  800728:	8d 50 e0             	lea    -0x20(%eax),%edx
  80072b:	83 fa 5e             	cmp    $0x5e,%edx
  80072e:	76 12                	jbe    800742 <vprintfmt+0x245>
					putch('?', putdat);
  800730:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800734:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80073b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80073e:	66 90                	xchg   %ax,%ax
  800740:	eb 0a                	jmp    80074c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800742:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800746:	89 04 24             	mov    %eax,(%esp)
  800749:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80074c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800750:	0f be 03             	movsbl (%ebx),%eax
  800753:	85 c0                	test   %eax,%eax
  800755:	74 05                	je     80075c <vprintfmt+0x25f>
  800757:	83 c3 01             	add    $0x1,%ebx
  80075a:	eb 29                	jmp    800785 <vprintfmt+0x288>
  80075c:	89 fe                	mov    %edi,%esi
  80075e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800761:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800764:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800768:	7f 2e                	jg     800798 <vprintfmt+0x29b>
  80076a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80076d:	e9 b7 fd ff ff       	jmp    800529 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800772:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800775:	83 c2 01             	add    $0x1,%edx
  800778:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80077b:	89 f7                	mov    %esi,%edi
  80077d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800780:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800783:	89 d3                	mov    %edx,%ebx
  800785:	85 f6                	test   %esi,%esi
  800787:	78 99                	js     800722 <vprintfmt+0x225>
  800789:	83 ee 01             	sub    $0x1,%esi
  80078c:	79 94                	jns    800722 <vprintfmt+0x225>
  80078e:	89 fe                	mov    %edi,%esi
  800790:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800793:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800796:	eb cc                	jmp    800764 <vprintfmt+0x267>
  800798:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80079b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80079e:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007a2:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  8007a9:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8007ab:	83 eb 01             	sub    $0x1,%ebx
  8007ae:	85 db                	test   %ebx,%ebx
  8007b0:	7f ec                	jg     80079e <vprintfmt+0x2a1>
  8007b2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  8007b5:	e9 6f fd ff ff       	jmp    800529 <vprintfmt+0x2c>
  8007ba:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  8007bd:	83 f9 01             	cmp    $0x1,%ecx
  8007c0:	7e 16                	jle    8007d8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  8007c2:	8b 45 14             	mov    0x14(%ebp),%eax
  8007c5:	8d 50 08             	lea    0x8(%eax),%edx
  8007c8:	89 55 14             	mov    %edx,0x14(%ebp)
  8007cb:	8b 10                	mov    (%eax),%edx
  8007cd:	8b 48 04             	mov    0x4(%eax),%ecx
  8007d0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8007d3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8007d6:	eb 32                	jmp    80080a <vprintfmt+0x30d>
	else if (lflag)
  8007d8:	85 c9                	test   %ecx,%ecx
  8007da:	74 18                	je     8007f4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8007dc:	8b 45 14             	mov    0x14(%ebp),%eax
  8007df:	8d 50 04             	lea    0x4(%eax),%edx
  8007e2:	89 55 14             	mov    %edx,0x14(%ebp)
  8007e5:	8b 00                	mov    (%eax),%eax
  8007e7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007ea:	89 c1                	mov    %eax,%ecx
  8007ec:	c1 f9 1f             	sar    $0x1f,%ecx
  8007ef:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8007f2:	eb 16                	jmp    80080a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8007f4:	8b 45 14             	mov    0x14(%ebp),%eax
  8007f7:	8d 50 04             	lea    0x4(%eax),%edx
  8007fa:	89 55 14             	mov    %edx,0x14(%ebp)
  8007fd:	8b 00                	mov    (%eax),%eax
  8007ff:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800802:	89 c2                	mov    %eax,%edx
  800804:	c1 fa 1f             	sar    $0x1f,%edx
  800807:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80080a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80080d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800810:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800815:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800819:	0f 89 9b 00 00 00    	jns    8008ba <vprintfmt+0x3bd>
				putch('-', putdat);
  80081f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800823:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80082a:	ff d7                	call   *%edi
				num = -(long long) num;
  80082c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80082f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800832:	f7 d9                	neg    %ecx
  800834:	83 d3 00             	adc    $0x0,%ebx
  800837:	f7 db                	neg    %ebx
  800839:	b8 0a 00 00 00       	mov    $0xa,%eax
  80083e:	eb 7a                	jmp    8008ba <vprintfmt+0x3bd>
  800840:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800843:	89 ca                	mov    %ecx,%edx
  800845:	8d 45 14             	lea    0x14(%ebp),%eax
  800848:	e8 59 fc ff ff       	call   8004a6 <getuint>
  80084d:	89 c1                	mov    %eax,%ecx
  80084f:	89 d3                	mov    %edx,%ebx
  800851:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800856:	eb 62                	jmp    8008ba <vprintfmt+0x3bd>
  800858:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80085b:	89 ca                	mov    %ecx,%edx
  80085d:	8d 45 14             	lea    0x14(%ebp),%eax
  800860:	e8 41 fc ff ff       	call   8004a6 <getuint>
  800865:	89 c1                	mov    %eax,%ecx
  800867:	89 d3                	mov    %edx,%ebx
  800869:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80086e:	eb 4a                	jmp    8008ba <vprintfmt+0x3bd>
  800870:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800873:	89 74 24 04          	mov    %esi,0x4(%esp)
  800877:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80087e:	ff d7                	call   *%edi
			putch('x', putdat);
  800880:	89 74 24 04          	mov    %esi,0x4(%esp)
  800884:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80088b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80088d:	8b 45 14             	mov    0x14(%ebp),%eax
  800890:	8d 50 04             	lea    0x4(%eax),%edx
  800893:	89 55 14             	mov    %edx,0x14(%ebp)
  800896:	8b 08                	mov    (%eax),%ecx
  800898:	bb 00 00 00 00       	mov    $0x0,%ebx
  80089d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  8008a2:	eb 16                	jmp    8008ba <vprintfmt+0x3bd>
  8008a4:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  8008a7:	89 ca                	mov    %ecx,%edx
  8008a9:	8d 45 14             	lea    0x14(%ebp),%eax
  8008ac:	e8 f5 fb ff ff       	call   8004a6 <getuint>
  8008b1:	89 c1                	mov    %eax,%ecx
  8008b3:	89 d3                	mov    %edx,%ebx
  8008b5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  8008ba:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  8008be:	89 54 24 10          	mov    %edx,0x10(%esp)
  8008c2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8008c5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8008c9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008cd:	89 0c 24             	mov    %ecx,(%esp)
  8008d0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8008d4:	89 f2                	mov    %esi,%edx
  8008d6:	89 f8                	mov    %edi,%eax
  8008d8:	e8 d3 fa ff ff       	call   8003b0 <printnum>
  8008dd:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8008e0:	e9 44 fc ff ff       	jmp    800529 <vprintfmt+0x2c>
  8008e5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8008e8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  8008eb:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008ef:	89 14 24             	mov    %edx,(%esp)
  8008f2:	ff d7                	call   *%edi
  8008f4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8008f7:	e9 2d fc ff ff       	jmp    800529 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8008fc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800900:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800907:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800909:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80090c:	80 38 25             	cmpb   $0x25,(%eax)
  80090f:	0f 84 14 fc ff ff    	je     800529 <vprintfmt+0x2c>
  800915:	89 c3                	mov    %eax,%ebx
  800917:	eb f0                	jmp    800909 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800919:	83 c4 5c             	add    $0x5c,%esp
  80091c:	5b                   	pop    %ebx
  80091d:	5e                   	pop    %esi
  80091e:	5f                   	pop    %edi
  80091f:	5d                   	pop    %ebp
  800920:	c3                   	ret    

00800921 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800921:	55                   	push   %ebp
  800922:	89 e5                	mov    %esp,%ebp
  800924:	83 ec 28             	sub    $0x28,%esp
  800927:	8b 45 08             	mov    0x8(%ebp),%eax
  80092a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  80092d:	85 c0                	test   %eax,%eax
  80092f:	74 04                	je     800935 <vsnprintf+0x14>
  800931:	85 d2                	test   %edx,%edx
  800933:	7f 07                	jg     80093c <vsnprintf+0x1b>
  800935:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80093a:	eb 3b                	jmp    800977 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  80093c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80093f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800943:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800946:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  80094d:	8b 45 14             	mov    0x14(%ebp),%eax
  800950:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800954:	8b 45 10             	mov    0x10(%ebp),%eax
  800957:	89 44 24 08          	mov    %eax,0x8(%esp)
  80095b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80095e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800962:	c7 04 24 e0 04 80 00 	movl   $0x8004e0,(%esp)
  800969:	e8 8f fb ff ff       	call   8004fd <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  80096e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800971:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800974:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800977:	c9                   	leave  
  800978:	c3                   	ret    

00800979 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800979:	55                   	push   %ebp
  80097a:	89 e5                	mov    %esp,%ebp
  80097c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  80097f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800982:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800986:	8b 45 10             	mov    0x10(%ebp),%eax
  800989:	89 44 24 08          	mov    %eax,0x8(%esp)
  80098d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800990:	89 44 24 04          	mov    %eax,0x4(%esp)
  800994:	8b 45 08             	mov    0x8(%ebp),%eax
  800997:	89 04 24             	mov    %eax,(%esp)
  80099a:	e8 82 ff ff ff       	call   800921 <vsnprintf>
	va_end(ap);

	return rc;
}
  80099f:	c9                   	leave  
  8009a0:	c3                   	ret    

008009a1 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  8009a1:	55                   	push   %ebp
  8009a2:	89 e5                	mov    %esp,%ebp
  8009a4:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  8009a7:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  8009aa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8009ae:	8b 45 10             	mov    0x10(%ebp),%eax
  8009b1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8009b5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8009b8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8009bc:	8b 45 08             	mov    0x8(%ebp),%eax
  8009bf:	89 04 24             	mov    %eax,(%esp)
  8009c2:	e8 36 fb ff ff       	call   8004fd <vprintfmt>
	va_end(ap);
}
  8009c7:	c9                   	leave  
  8009c8:	c3                   	ret    
  8009c9:	00 00                	add    %al,(%eax)
  8009cb:	00 00                	add    %al,(%eax)
  8009cd:	00 00                	add    %al,(%eax)
	...

008009d0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  8009d0:	55                   	push   %ebp
  8009d1:	89 e5                	mov    %esp,%ebp
  8009d3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  8009d6:	b8 00 00 00 00       	mov    $0x0,%eax
  8009db:	80 3a 00             	cmpb   $0x0,(%edx)
  8009de:	74 09                	je     8009e9 <strlen+0x19>
		n++;
  8009e0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  8009e3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  8009e7:	75 f7                	jne    8009e0 <strlen+0x10>
		n++;
	return n;
}
  8009e9:	5d                   	pop    %ebp
  8009ea:	c3                   	ret    

008009eb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  8009eb:	55                   	push   %ebp
  8009ec:	89 e5                	mov    %esp,%ebp
  8009ee:	53                   	push   %ebx
  8009ef:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8009f2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009f5:	85 c9                	test   %ecx,%ecx
  8009f7:	74 19                	je     800a12 <strnlen+0x27>
  8009f9:	80 3b 00             	cmpb   $0x0,(%ebx)
  8009fc:	74 14                	je     800a12 <strnlen+0x27>
  8009fe:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800a03:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800a06:	39 c8                	cmp    %ecx,%eax
  800a08:	74 0d                	je     800a17 <strnlen+0x2c>
  800a0a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800a0e:	75 f3                	jne    800a03 <strnlen+0x18>
  800a10:	eb 05                	jmp    800a17 <strnlen+0x2c>
  800a12:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800a17:	5b                   	pop    %ebx
  800a18:	5d                   	pop    %ebp
  800a19:	c3                   	ret    

00800a1a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800a1a:	55                   	push   %ebp
  800a1b:	89 e5                	mov    %esp,%ebp
  800a1d:	53                   	push   %ebx
  800a1e:	8b 45 08             	mov    0x8(%ebp),%eax
  800a21:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800a24:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800a29:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800a2d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800a30:	83 c2 01             	add    $0x1,%edx
  800a33:	84 c9                	test   %cl,%cl
  800a35:	75 f2                	jne    800a29 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800a37:	5b                   	pop    %ebx
  800a38:	5d                   	pop    %ebp
  800a39:	c3                   	ret    

00800a3a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800a3a:	55                   	push   %ebp
  800a3b:	89 e5                	mov    %esp,%ebp
  800a3d:	56                   	push   %esi
  800a3e:	53                   	push   %ebx
  800a3f:	8b 45 08             	mov    0x8(%ebp),%eax
  800a42:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a45:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800a48:	85 f6                	test   %esi,%esi
  800a4a:	74 18                	je     800a64 <strncpy+0x2a>
  800a4c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800a51:	0f b6 1a             	movzbl (%edx),%ebx
  800a54:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800a57:	80 3a 01             	cmpb   $0x1,(%edx)
  800a5a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800a5d:	83 c1 01             	add    $0x1,%ecx
  800a60:	39 ce                	cmp    %ecx,%esi
  800a62:	77 ed                	ja     800a51 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800a64:	5b                   	pop    %ebx
  800a65:	5e                   	pop    %esi
  800a66:	5d                   	pop    %ebp
  800a67:	c3                   	ret    

00800a68 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800a68:	55                   	push   %ebp
  800a69:	89 e5                	mov    %esp,%ebp
  800a6b:	56                   	push   %esi
  800a6c:	53                   	push   %ebx
  800a6d:	8b 75 08             	mov    0x8(%ebp),%esi
  800a70:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a73:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800a76:	89 f0                	mov    %esi,%eax
  800a78:	85 c9                	test   %ecx,%ecx
  800a7a:	74 27                	je     800aa3 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800a7c:	83 e9 01             	sub    $0x1,%ecx
  800a7f:	74 1d                	je     800a9e <strlcpy+0x36>
  800a81:	0f b6 1a             	movzbl (%edx),%ebx
  800a84:	84 db                	test   %bl,%bl
  800a86:	74 16                	je     800a9e <strlcpy+0x36>
			*dst++ = *src++;
  800a88:	88 18                	mov    %bl,(%eax)
  800a8a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a8d:	83 e9 01             	sub    $0x1,%ecx
  800a90:	74 0e                	je     800aa0 <strlcpy+0x38>
			*dst++ = *src++;
  800a92:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a95:	0f b6 1a             	movzbl (%edx),%ebx
  800a98:	84 db                	test   %bl,%bl
  800a9a:	75 ec                	jne    800a88 <strlcpy+0x20>
  800a9c:	eb 02                	jmp    800aa0 <strlcpy+0x38>
  800a9e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800aa0:	c6 00 00             	movb   $0x0,(%eax)
  800aa3:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800aa5:	5b                   	pop    %ebx
  800aa6:	5e                   	pop    %esi
  800aa7:	5d                   	pop    %ebp
  800aa8:	c3                   	ret    

00800aa9 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800aa9:	55                   	push   %ebp
  800aaa:	89 e5                	mov    %esp,%ebp
  800aac:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800aaf:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800ab2:	0f b6 01             	movzbl (%ecx),%eax
  800ab5:	84 c0                	test   %al,%al
  800ab7:	74 15                	je     800ace <strcmp+0x25>
  800ab9:	3a 02                	cmp    (%edx),%al
  800abb:	75 11                	jne    800ace <strcmp+0x25>
		p++, q++;
  800abd:	83 c1 01             	add    $0x1,%ecx
  800ac0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800ac3:	0f b6 01             	movzbl (%ecx),%eax
  800ac6:	84 c0                	test   %al,%al
  800ac8:	74 04                	je     800ace <strcmp+0x25>
  800aca:	3a 02                	cmp    (%edx),%al
  800acc:	74 ef                	je     800abd <strcmp+0x14>
  800ace:	0f b6 c0             	movzbl %al,%eax
  800ad1:	0f b6 12             	movzbl (%edx),%edx
  800ad4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ad6:	5d                   	pop    %ebp
  800ad7:	c3                   	ret    

00800ad8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800ad8:	55                   	push   %ebp
  800ad9:	89 e5                	mov    %esp,%ebp
  800adb:	53                   	push   %ebx
  800adc:	8b 55 08             	mov    0x8(%ebp),%edx
  800adf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ae2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800ae5:	85 c0                	test   %eax,%eax
  800ae7:	74 23                	je     800b0c <strncmp+0x34>
  800ae9:	0f b6 1a             	movzbl (%edx),%ebx
  800aec:	84 db                	test   %bl,%bl
  800aee:	74 24                	je     800b14 <strncmp+0x3c>
  800af0:	3a 19                	cmp    (%ecx),%bl
  800af2:	75 20                	jne    800b14 <strncmp+0x3c>
  800af4:	83 e8 01             	sub    $0x1,%eax
  800af7:	74 13                	je     800b0c <strncmp+0x34>
		n--, p++, q++;
  800af9:	83 c2 01             	add    $0x1,%edx
  800afc:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800aff:	0f b6 1a             	movzbl (%edx),%ebx
  800b02:	84 db                	test   %bl,%bl
  800b04:	74 0e                	je     800b14 <strncmp+0x3c>
  800b06:	3a 19                	cmp    (%ecx),%bl
  800b08:	74 ea                	je     800af4 <strncmp+0x1c>
  800b0a:	eb 08                	jmp    800b14 <strncmp+0x3c>
  800b0c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800b11:	5b                   	pop    %ebx
  800b12:	5d                   	pop    %ebp
  800b13:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800b14:	0f b6 02             	movzbl (%edx),%eax
  800b17:	0f b6 11             	movzbl (%ecx),%edx
  800b1a:	29 d0                	sub    %edx,%eax
  800b1c:	eb f3                	jmp    800b11 <strncmp+0x39>

00800b1e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800b1e:	55                   	push   %ebp
  800b1f:	89 e5                	mov    %esp,%ebp
  800b21:	8b 45 08             	mov    0x8(%ebp),%eax
  800b24:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b28:	0f b6 10             	movzbl (%eax),%edx
  800b2b:	84 d2                	test   %dl,%dl
  800b2d:	74 15                	je     800b44 <strchr+0x26>
		if (*s == c)
  800b2f:	38 ca                	cmp    %cl,%dl
  800b31:	75 07                	jne    800b3a <strchr+0x1c>
  800b33:	eb 14                	jmp    800b49 <strchr+0x2b>
  800b35:	38 ca                	cmp    %cl,%dl
  800b37:	90                   	nop
  800b38:	74 0f                	je     800b49 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800b3a:	83 c0 01             	add    $0x1,%eax
  800b3d:	0f b6 10             	movzbl (%eax),%edx
  800b40:	84 d2                	test   %dl,%dl
  800b42:	75 f1                	jne    800b35 <strchr+0x17>
  800b44:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800b49:	5d                   	pop    %ebp
  800b4a:	c3                   	ret    

00800b4b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800b4b:	55                   	push   %ebp
  800b4c:	89 e5                	mov    %esp,%ebp
  800b4e:	8b 45 08             	mov    0x8(%ebp),%eax
  800b51:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b55:	0f b6 10             	movzbl (%eax),%edx
  800b58:	84 d2                	test   %dl,%dl
  800b5a:	74 18                	je     800b74 <strfind+0x29>
		if (*s == c)
  800b5c:	38 ca                	cmp    %cl,%dl
  800b5e:	75 0a                	jne    800b6a <strfind+0x1f>
  800b60:	eb 12                	jmp    800b74 <strfind+0x29>
  800b62:	38 ca                	cmp    %cl,%dl
  800b64:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800b68:	74 0a                	je     800b74 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800b6a:	83 c0 01             	add    $0x1,%eax
  800b6d:	0f b6 10             	movzbl (%eax),%edx
  800b70:	84 d2                	test   %dl,%dl
  800b72:	75 ee                	jne    800b62 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800b74:	5d                   	pop    %ebp
  800b75:	c3                   	ret    

00800b76 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800b76:	55                   	push   %ebp
  800b77:	89 e5                	mov    %esp,%ebp
  800b79:	83 ec 0c             	sub    $0xc,%esp
  800b7c:	89 1c 24             	mov    %ebx,(%esp)
  800b7f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b83:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800b87:	8b 7d 08             	mov    0x8(%ebp),%edi
  800b8a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b8d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800b90:	85 c9                	test   %ecx,%ecx
  800b92:	74 30                	je     800bc4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b94:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b9a:	75 25                	jne    800bc1 <memset+0x4b>
  800b9c:	f6 c1 03             	test   $0x3,%cl
  800b9f:	75 20                	jne    800bc1 <memset+0x4b>
		c &= 0xFF;
  800ba1:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800ba4:	89 d3                	mov    %edx,%ebx
  800ba6:	c1 e3 08             	shl    $0x8,%ebx
  800ba9:	89 d6                	mov    %edx,%esi
  800bab:	c1 e6 18             	shl    $0x18,%esi
  800bae:	89 d0                	mov    %edx,%eax
  800bb0:	c1 e0 10             	shl    $0x10,%eax
  800bb3:	09 f0                	or     %esi,%eax
  800bb5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800bb7:	09 d8                	or     %ebx,%eax
  800bb9:	c1 e9 02             	shr    $0x2,%ecx
  800bbc:	fc                   	cld    
  800bbd:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800bbf:	eb 03                	jmp    800bc4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800bc1:	fc                   	cld    
  800bc2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800bc4:	89 f8                	mov    %edi,%eax
  800bc6:	8b 1c 24             	mov    (%esp),%ebx
  800bc9:	8b 74 24 04          	mov    0x4(%esp),%esi
  800bcd:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800bd1:	89 ec                	mov    %ebp,%esp
  800bd3:	5d                   	pop    %ebp
  800bd4:	c3                   	ret    

00800bd5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800bd5:	55                   	push   %ebp
  800bd6:	89 e5                	mov    %esp,%ebp
  800bd8:	83 ec 08             	sub    $0x8,%esp
  800bdb:	89 34 24             	mov    %esi,(%esp)
  800bde:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800be2:	8b 45 08             	mov    0x8(%ebp),%eax
  800be5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800be8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800beb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800bed:	39 c6                	cmp    %eax,%esi
  800bef:	73 35                	jae    800c26 <memmove+0x51>
  800bf1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800bf4:	39 d0                	cmp    %edx,%eax
  800bf6:	73 2e                	jae    800c26 <memmove+0x51>
		s += n;
		d += n;
  800bf8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bfa:	f6 c2 03             	test   $0x3,%dl
  800bfd:	75 1b                	jne    800c1a <memmove+0x45>
  800bff:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800c05:	75 13                	jne    800c1a <memmove+0x45>
  800c07:	f6 c1 03             	test   $0x3,%cl
  800c0a:	75 0e                	jne    800c1a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800c0c:	83 ef 04             	sub    $0x4,%edi
  800c0f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800c12:	c1 e9 02             	shr    $0x2,%ecx
  800c15:	fd                   	std    
  800c16:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800c18:	eb 09                	jmp    800c23 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800c1a:	83 ef 01             	sub    $0x1,%edi
  800c1d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800c20:	fd                   	std    
  800c21:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800c23:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800c24:	eb 20                	jmp    800c46 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800c26:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800c2c:	75 15                	jne    800c43 <memmove+0x6e>
  800c2e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800c34:	75 0d                	jne    800c43 <memmove+0x6e>
  800c36:	f6 c1 03             	test   $0x3,%cl
  800c39:	75 08                	jne    800c43 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800c3b:	c1 e9 02             	shr    $0x2,%ecx
  800c3e:	fc                   	cld    
  800c3f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800c41:	eb 03                	jmp    800c46 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800c43:	fc                   	cld    
  800c44:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800c46:	8b 34 24             	mov    (%esp),%esi
  800c49:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800c4d:	89 ec                	mov    %ebp,%esp
  800c4f:	5d                   	pop    %ebp
  800c50:	c3                   	ret    

00800c51 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800c51:	55                   	push   %ebp
  800c52:	89 e5                	mov    %esp,%ebp
  800c54:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800c57:	8b 45 10             	mov    0x10(%ebp),%eax
  800c5a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800c5e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c61:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c65:	8b 45 08             	mov    0x8(%ebp),%eax
  800c68:	89 04 24             	mov    %eax,(%esp)
  800c6b:	e8 65 ff ff ff       	call   800bd5 <memmove>
}
  800c70:	c9                   	leave  
  800c71:	c3                   	ret    

00800c72 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800c72:	55                   	push   %ebp
  800c73:	89 e5                	mov    %esp,%ebp
  800c75:	57                   	push   %edi
  800c76:	56                   	push   %esi
  800c77:	53                   	push   %ebx
  800c78:	8b 75 08             	mov    0x8(%ebp),%esi
  800c7b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800c7e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c81:	85 c9                	test   %ecx,%ecx
  800c83:	74 36                	je     800cbb <memcmp+0x49>
		if (*s1 != *s2)
  800c85:	0f b6 06             	movzbl (%esi),%eax
  800c88:	0f b6 1f             	movzbl (%edi),%ebx
  800c8b:	38 d8                	cmp    %bl,%al
  800c8d:	74 20                	je     800caf <memcmp+0x3d>
  800c8f:	eb 14                	jmp    800ca5 <memcmp+0x33>
  800c91:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800c96:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800c9b:	83 c2 01             	add    $0x1,%edx
  800c9e:	83 e9 01             	sub    $0x1,%ecx
  800ca1:	38 d8                	cmp    %bl,%al
  800ca3:	74 12                	je     800cb7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800ca5:	0f b6 c0             	movzbl %al,%eax
  800ca8:	0f b6 db             	movzbl %bl,%ebx
  800cab:	29 d8                	sub    %ebx,%eax
  800cad:	eb 11                	jmp    800cc0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800caf:	83 e9 01             	sub    $0x1,%ecx
  800cb2:	ba 00 00 00 00       	mov    $0x0,%edx
  800cb7:	85 c9                	test   %ecx,%ecx
  800cb9:	75 d6                	jne    800c91 <memcmp+0x1f>
  800cbb:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800cc0:	5b                   	pop    %ebx
  800cc1:	5e                   	pop    %esi
  800cc2:	5f                   	pop    %edi
  800cc3:	5d                   	pop    %ebp
  800cc4:	c3                   	ret    

00800cc5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800cc5:	55                   	push   %ebp
  800cc6:	89 e5                	mov    %esp,%ebp
  800cc8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800ccb:	89 c2                	mov    %eax,%edx
  800ccd:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800cd0:	39 d0                	cmp    %edx,%eax
  800cd2:	73 15                	jae    800ce9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800cd4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800cd8:	38 08                	cmp    %cl,(%eax)
  800cda:	75 06                	jne    800ce2 <memfind+0x1d>
  800cdc:	eb 0b                	jmp    800ce9 <memfind+0x24>
  800cde:	38 08                	cmp    %cl,(%eax)
  800ce0:	74 07                	je     800ce9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800ce2:	83 c0 01             	add    $0x1,%eax
  800ce5:	39 c2                	cmp    %eax,%edx
  800ce7:	77 f5                	ja     800cde <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800ce9:	5d                   	pop    %ebp
  800cea:	c3                   	ret    

00800ceb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800ceb:	55                   	push   %ebp
  800cec:	89 e5                	mov    %esp,%ebp
  800cee:	57                   	push   %edi
  800cef:	56                   	push   %esi
  800cf0:	53                   	push   %ebx
  800cf1:	83 ec 04             	sub    $0x4,%esp
  800cf4:	8b 55 08             	mov    0x8(%ebp),%edx
  800cf7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800cfa:	0f b6 02             	movzbl (%edx),%eax
  800cfd:	3c 20                	cmp    $0x20,%al
  800cff:	74 04                	je     800d05 <strtol+0x1a>
  800d01:	3c 09                	cmp    $0x9,%al
  800d03:	75 0e                	jne    800d13 <strtol+0x28>
		s++;
  800d05:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800d08:	0f b6 02             	movzbl (%edx),%eax
  800d0b:	3c 20                	cmp    $0x20,%al
  800d0d:	74 f6                	je     800d05 <strtol+0x1a>
  800d0f:	3c 09                	cmp    $0x9,%al
  800d11:	74 f2                	je     800d05 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800d13:	3c 2b                	cmp    $0x2b,%al
  800d15:	75 0c                	jne    800d23 <strtol+0x38>
		s++;
  800d17:	83 c2 01             	add    $0x1,%edx
  800d1a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800d21:	eb 15                	jmp    800d38 <strtol+0x4d>
	else if (*s == '-')
  800d23:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800d2a:	3c 2d                	cmp    $0x2d,%al
  800d2c:	75 0a                	jne    800d38 <strtol+0x4d>
		s++, neg = 1;
  800d2e:	83 c2 01             	add    $0x1,%edx
  800d31:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800d38:	85 db                	test   %ebx,%ebx
  800d3a:	0f 94 c0             	sete   %al
  800d3d:	74 05                	je     800d44 <strtol+0x59>
  800d3f:	83 fb 10             	cmp    $0x10,%ebx
  800d42:	75 18                	jne    800d5c <strtol+0x71>
  800d44:	80 3a 30             	cmpb   $0x30,(%edx)
  800d47:	75 13                	jne    800d5c <strtol+0x71>
  800d49:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800d4d:	8d 76 00             	lea    0x0(%esi),%esi
  800d50:	75 0a                	jne    800d5c <strtol+0x71>
		s += 2, base = 16;
  800d52:	83 c2 02             	add    $0x2,%edx
  800d55:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800d5a:	eb 15                	jmp    800d71 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d5c:	84 c0                	test   %al,%al
  800d5e:	66 90                	xchg   %ax,%ax
  800d60:	74 0f                	je     800d71 <strtol+0x86>
  800d62:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800d67:	80 3a 30             	cmpb   $0x30,(%edx)
  800d6a:	75 05                	jne    800d71 <strtol+0x86>
		s++, base = 8;
  800d6c:	83 c2 01             	add    $0x1,%edx
  800d6f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d71:	b8 00 00 00 00       	mov    $0x0,%eax
  800d76:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800d78:	0f b6 0a             	movzbl (%edx),%ecx
  800d7b:	89 cf                	mov    %ecx,%edi
  800d7d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800d80:	80 fb 09             	cmp    $0x9,%bl
  800d83:	77 08                	ja     800d8d <strtol+0xa2>
			dig = *s - '0';
  800d85:	0f be c9             	movsbl %cl,%ecx
  800d88:	83 e9 30             	sub    $0x30,%ecx
  800d8b:	eb 1e                	jmp    800dab <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800d8d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800d90:	80 fb 19             	cmp    $0x19,%bl
  800d93:	77 08                	ja     800d9d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800d95:	0f be c9             	movsbl %cl,%ecx
  800d98:	83 e9 57             	sub    $0x57,%ecx
  800d9b:	eb 0e                	jmp    800dab <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800d9d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800da0:	80 fb 19             	cmp    $0x19,%bl
  800da3:	77 15                	ja     800dba <strtol+0xcf>
			dig = *s - 'A' + 10;
  800da5:	0f be c9             	movsbl %cl,%ecx
  800da8:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800dab:	39 f1                	cmp    %esi,%ecx
  800dad:	7d 0b                	jge    800dba <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800daf:	83 c2 01             	add    $0x1,%edx
  800db2:	0f af c6             	imul   %esi,%eax
  800db5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800db8:	eb be                	jmp    800d78 <strtol+0x8d>
  800dba:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800dbc:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800dc0:	74 05                	je     800dc7 <strtol+0xdc>
		*endptr = (char *) s;
  800dc2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800dc5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800dc7:	89 ca                	mov    %ecx,%edx
  800dc9:	f7 da                	neg    %edx
  800dcb:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800dcf:	0f 45 c2             	cmovne %edx,%eax
}
  800dd2:	83 c4 04             	add    $0x4,%esp
  800dd5:	5b                   	pop    %ebx
  800dd6:	5e                   	pop    %esi
  800dd7:	5f                   	pop    %edi
  800dd8:	5d                   	pop    %ebp
  800dd9:	c3                   	ret    
	...

00800ddc <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800ddc:	55                   	push   %ebp
  800ddd:	89 e5                	mov    %esp,%ebp
  800ddf:	83 ec 0c             	sub    $0xc,%esp
  800de2:	89 1c 24             	mov    %ebx,(%esp)
  800de5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800de9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ded:	ba 00 00 00 00       	mov    $0x0,%edx
  800df2:	b8 01 00 00 00       	mov    $0x1,%eax
  800df7:	89 d1                	mov    %edx,%ecx
  800df9:	89 d3                	mov    %edx,%ebx
  800dfb:	89 d7                	mov    %edx,%edi
  800dfd:	89 d6                	mov    %edx,%esi
  800dff:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800e01:	8b 1c 24             	mov    (%esp),%ebx
  800e04:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e08:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e0c:	89 ec                	mov    %ebp,%esp
  800e0e:	5d                   	pop    %ebp
  800e0f:	c3                   	ret    

00800e10 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800e10:	55                   	push   %ebp
  800e11:	89 e5                	mov    %esp,%ebp
  800e13:	83 ec 0c             	sub    $0xc,%esp
  800e16:	89 1c 24             	mov    %ebx,(%esp)
  800e19:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e1d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e21:	b8 00 00 00 00       	mov    $0x0,%eax
  800e26:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e29:	8b 55 08             	mov    0x8(%ebp),%edx
  800e2c:	89 c3                	mov    %eax,%ebx
  800e2e:	89 c7                	mov    %eax,%edi
  800e30:	89 c6                	mov    %eax,%esi
  800e32:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800e34:	8b 1c 24             	mov    (%esp),%ebx
  800e37:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e3b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e3f:	89 ec                	mov    %ebp,%esp
  800e41:	5d                   	pop    %ebp
  800e42:	c3                   	ret    

00800e43 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800e43:	55                   	push   %ebp
  800e44:	89 e5                	mov    %esp,%ebp
  800e46:	83 ec 0c             	sub    $0xc,%esp
  800e49:	89 1c 24             	mov    %ebx,(%esp)
  800e4c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e50:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e54:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e59:	b8 10 00 00 00       	mov    $0x10,%eax
  800e5e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e61:	8b 55 08             	mov    0x8(%ebp),%edx
  800e64:	89 df                	mov    %ebx,%edi
  800e66:	89 de                	mov    %ebx,%esi
  800e68:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e6a:	8b 1c 24             	mov    (%esp),%ebx
  800e6d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e71:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e75:	89 ec                	mov    %ebp,%esp
  800e77:	5d                   	pop    %ebp
  800e78:	c3                   	ret    

00800e79 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800e79:	55                   	push   %ebp
  800e7a:	89 e5                	mov    %esp,%ebp
  800e7c:	83 ec 0c             	sub    $0xc,%esp
  800e7f:	89 1c 24             	mov    %ebx,(%esp)
  800e82:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e86:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e8a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e8f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800e94:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e97:	8b 55 08             	mov    0x8(%ebp),%edx
  800e9a:	89 df                	mov    %ebx,%edi
  800e9c:	89 de                	mov    %ebx,%esi
  800e9e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800ea0:	8b 1c 24             	mov    (%esp),%ebx
  800ea3:	8b 74 24 04          	mov    0x4(%esp),%esi
  800ea7:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800eab:	89 ec                	mov    %ebp,%esp
  800ead:	5d                   	pop    %ebp
  800eae:	c3                   	ret    

00800eaf <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800eaf:	55                   	push   %ebp
  800eb0:	89 e5                	mov    %esp,%ebp
  800eb2:	83 ec 0c             	sub    $0xc,%esp
  800eb5:	89 1c 24             	mov    %ebx,(%esp)
  800eb8:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ebc:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ec0:	ba 00 00 00 00       	mov    $0x0,%edx
  800ec5:	b8 0e 00 00 00       	mov    $0xe,%eax
  800eca:	89 d1                	mov    %edx,%ecx
  800ecc:	89 d3                	mov    %edx,%ebx
  800ece:	89 d7                	mov    %edx,%edi
  800ed0:	89 d6                	mov    %edx,%esi
  800ed2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800ed4:	8b 1c 24             	mov    (%esp),%ebx
  800ed7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800edb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800edf:	89 ec                	mov    %ebp,%esp
  800ee1:	5d                   	pop    %ebp
  800ee2:	c3                   	ret    

00800ee3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800ee3:	55                   	push   %ebp
  800ee4:	89 e5                	mov    %esp,%ebp
  800ee6:	83 ec 38             	sub    $0x38,%esp
  800ee9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800eec:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800eef:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ef2:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ef7:	b8 0d 00 00 00       	mov    $0xd,%eax
  800efc:	8b 55 08             	mov    0x8(%ebp),%edx
  800eff:	89 cb                	mov    %ecx,%ebx
  800f01:	89 cf                	mov    %ecx,%edi
  800f03:	89 ce                	mov    %ecx,%esi
  800f05:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f07:	85 c0                	test   %eax,%eax
  800f09:	7e 28                	jle    800f33 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f0b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f0f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800f16:	00 
  800f17:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  800f1e:	00 
  800f1f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f26:	00 
  800f27:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  800f2e:	e8 59 f3 ff ff       	call   80028c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800f33:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f36:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f39:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f3c:	89 ec                	mov    %ebp,%esp
  800f3e:	5d                   	pop    %ebp
  800f3f:	c3                   	ret    

00800f40 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800f40:	55                   	push   %ebp
  800f41:	89 e5                	mov    %esp,%ebp
  800f43:	83 ec 38             	sub    $0x38,%esp
  800f46:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f49:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f4c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f4f:	be 00 00 00 00       	mov    $0x0,%esi
  800f54:	b8 0c 00 00 00       	mov    $0xc,%eax
  800f59:	8b 7d 14             	mov    0x14(%ebp),%edi
  800f5c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800f5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f62:	8b 55 08             	mov    0x8(%ebp),%edx
  800f65:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f67:	85 c0                	test   %eax,%eax
  800f69:	7e 28                	jle    800f93 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f6b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f6f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800f76:	00 
  800f77:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  800f7e:	00 
  800f7f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f86:	00 
  800f87:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  800f8e:	e8 f9 f2 ff ff       	call   80028c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800f93:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f96:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f99:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f9c:	89 ec                	mov    %ebp,%esp
  800f9e:	5d                   	pop    %ebp
  800f9f:	c3                   	ret    

00800fa0 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800fa0:	55                   	push   %ebp
  800fa1:	89 e5                	mov    %esp,%ebp
  800fa3:	83 ec 38             	sub    $0x38,%esp
  800fa6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fa9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fac:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800faf:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fb4:	b8 0a 00 00 00       	mov    $0xa,%eax
  800fb9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fbc:	8b 55 08             	mov    0x8(%ebp),%edx
  800fbf:	89 df                	mov    %ebx,%edi
  800fc1:	89 de                	mov    %ebx,%esi
  800fc3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fc5:	85 c0                	test   %eax,%eax
  800fc7:	7e 28                	jle    800ff1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fc9:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fcd:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800fd4:	00 
  800fd5:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  800fdc:	00 
  800fdd:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fe4:	00 
  800fe5:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  800fec:	e8 9b f2 ff ff       	call   80028c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800ff1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ff4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ff7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ffa:	89 ec                	mov    %ebp,%esp
  800ffc:	5d                   	pop    %ebp
  800ffd:	c3                   	ret    

00800ffe <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800ffe:	55                   	push   %ebp
  800fff:	89 e5                	mov    %esp,%ebp
  801001:	83 ec 38             	sub    $0x38,%esp
  801004:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801007:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80100a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80100d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801012:	b8 09 00 00 00       	mov    $0x9,%eax
  801017:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80101a:	8b 55 08             	mov    0x8(%ebp),%edx
  80101d:	89 df                	mov    %ebx,%edi
  80101f:	89 de                	mov    %ebx,%esi
  801021:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801023:	85 c0                	test   %eax,%eax
  801025:	7e 28                	jle    80104f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801027:	89 44 24 10          	mov    %eax,0x10(%esp)
  80102b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801032:	00 
  801033:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  80103a:	00 
  80103b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801042:	00 
  801043:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  80104a:	e8 3d f2 ff ff       	call   80028c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80104f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801052:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801055:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801058:	89 ec                	mov    %ebp,%esp
  80105a:	5d                   	pop    %ebp
  80105b:	c3                   	ret    

0080105c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80105c:	55                   	push   %ebp
  80105d:	89 e5                	mov    %esp,%ebp
  80105f:	83 ec 38             	sub    $0x38,%esp
  801062:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801065:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801068:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80106b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801070:	b8 08 00 00 00       	mov    $0x8,%eax
  801075:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801078:	8b 55 08             	mov    0x8(%ebp),%edx
  80107b:	89 df                	mov    %ebx,%edi
  80107d:	89 de                	mov    %ebx,%esi
  80107f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801081:	85 c0                	test   %eax,%eax
  801083:	7e 28                	jle    8010ad <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801085:	89 44 24 10          	mov    %eax,0x10(%esp)
  801089:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801090:	00 
  801091:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  801098:	00 
  801099:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010a0:	00 
  8010a1:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  8010a8:	e8 df f1 ff ff       	call   80028c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  8010ad:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010b0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010b3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010b6:	89 ec                	mov    %ebp,%esp
  8010b8:	5d                   	pop    %ebp
  8010b9:	c3                   	ret    

008010ba <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  8010ba:	55                   	push   %ebp
  8010bb:	89 e5                	mov    %esp,%ebp
  8010bd:	83 ec 38             	sub    $0x38,%esp
  8010c0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010c3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010c6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010c9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8010ce:	b8 06 00 00 00       	mov    $0x6,%eax
  8010d3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8010d9:	89 df                	mov    %ebx,%edi
  8010db:	89 de                	mov    %ebx,%esi
  8010dd:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010df:	85 c0                	test   %eax,%eax
  8010e1:	7e 28                	jle    80110b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010e3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010e7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8010ee:	00 
  8010ef:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  8010f6:	00 
  8010f7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010fe:	00 
  8010ff:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  801106:	e8 81 f1 ff ff       	call   80028c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80110b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80110e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801111:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801114:	89 ec                	mov    %ebp,%esp
  801116:	5d                   	pop    %ebp
  801117:	c3                   	ret    

00801118 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801118:	55                   	push   %ebp
  801119:	89 e5                	mov    %esp,%ebp
  80111b:	83 ec 38             	sub    $0x38,%esp
  80111e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801121:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801124:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801127:	b8 05 00 00 00       	mov    $0x5,%eax
  80112c:	8b 75 18             	mov    0x18(%ebp),%esi
  80112f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801132:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801135:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801138:	8b 55 08             	mov    0x8(%ebp),%edx
  80113b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80113d:	85 c0                	test   %eax,%eax
  80113f:	7e 28                	jle    801169 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801141:	89 44 24 10          	mov    %eax,0x10(%esp)
  801145:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80114c:	00 
  80114d:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  801154:	00 
  801155:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80115c:	00 
  80115d:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  801164:	e8 23 f1 ff ff       	call   80028c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801169:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80116c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80116f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801172:	89 ec                	mov    %ebp,%esp
  801174:	5d                   	pop    %ebp
  801175:	c3                   	ret    

00801176 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801176:	55                   	push   %ebp
  801177:	89 e5                	mov    %esp,%ebp
  801179:	83 ec 38             	sub    $0x38,%esp
  80117c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80117f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801182:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801185:	be 00 00 00 00       	mov    $0x0,%esi
  80118a:	b8 04 00 00 00       	mov    $0x4,%eax
  80118f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801192:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801195:	8b 55 08             	mov    0x8(%ebp),%edx
  801198:	89 f7                	mov    %esi,%edi
  80119a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80119c:	85 c0                	test   %eax,%eax
  80119e:	7e 28                	jle    8011c8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011a0:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011a4:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  8011ab:	00 
  8011ac:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  8011b3:	00 
  8011b4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011bb:	00 
  8011bc:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  8011c3:	e8 c4 f0 ff ff       	call   80028c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8011c8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011cb:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011ce:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011d1:	89 ec                	mov    %ebp,%esp
  8011d3:	5d                   	pop    %ebp
  8011d4:	c3                   	ret    

008011d5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8011d5:	55                   	push   %ebp
  8011d6:	89 e5                	mov    %esp,%ebp
  8011d8:	83 ec 0c             	sub    $0xc,%esp
  8011db:	89 1c 24             	mov    %ebx,(%esp)
  8011de:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011e2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011e6:	ba 00 00 00 00       	mov    $0x0,%edx
  8011eb:	b8 0b 00 00 00       	mov    $0xb,%eax
  8011f0:	89 d1                	mov    %edx,%ecx
  8011f2:	89 d3                	mov    %edx,%ebx
  8011f4:	89 d7                	mov    %edx,%edi
  8011f6:	89 d6                	mov    %edx,%esi
  8011f8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8011fa:	8b 1c 24             	mov    (%esp),%ebx
  8011fd:	8b 74 24 04          	mov    0x4(%esp),%esi
  801201:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801205:	89 ec                	mov    %ebp,%esp
  801207:	5d                   	pop    %ebp
  801208:	c3                   	ret    

00801209 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801209:	55                   	push   %ebp
  80120a:	89 e5                	mov    %esp,%ebp
  80120c:	83 ec 0c             	sub    $0xc,%esp
  80120f:	89 1c 24             	mov    %ebx,(%esp)
  801212:	89 74 24 04          	mov    %esi,0x4(%esp)
  801216:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80121a:	ba 00 00 00 00       	mov    $0x0,%edx
  80121f:	b8 02 00 00 00       	mov    $0x2,%eax
  801224:	89 d1                	mov    %edx,%ecx
  801226:	89 d3                	mov    %edx,%ebx
  801228:	89 d7                	mov    %edx,%edi
  80122a:	89 d6                	mov    %edx,%esi
  80122c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80122e:	8b 1c 24             	mov    (%esp),%ebx
  801231:	8b 74 24 04          	mov    0x4(%esp),%esi
  801235:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801239:	89 ec                	mov    %ebp,%esp
  80123b:	5d                   	pop    %ebp
  80123c:	c3                   	ret    

0080123d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80123d:	55                   	push   %ebp
  80123e:	89 e5                	mov    %esp,%ebp
  801240:	83 ec 38             	sub    $0x38,%esp
  801243:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801246:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801249:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80124c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801251:	b8 03 00 00 00       	mov    $0x3,%eax
  801256:	8b 55 08             	mov    0x8(%ebp),%edx
  801259:	89 cb                	mov    %ecx,%ebx
  80125b:	89 cf                	mov    %ecx,%edi
  80125d:	89 ce                	mov    %ecx,%esi
  80125f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801261:	85 c0                	test   %eax,%eax
  801263:	7e 28                	jle    80128d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801265:	89 44 24 10          	mov    %eax,0x10(%esp)
  801269:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801270:	00 
  801271:	c7 44 24 08 ab 32 80 	movl   $0x8032ab,0x8(%esp)
  801278:	00 
  801279:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801280:	00 
  801281:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  801288:	e8 ff ef ff ff       	call   80028c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80128d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801290:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801293:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801296:	89 ec                	mov    %ebp,%esp
  801298:	5d                   	pop    %ebp
  801299:	c3                   	ret    
  80129a:	00 00                	add    %al,(%eax)
  80129c:	00 00                	add    %al,(%eax)
	...

008012a0 <sfork>:
}

// Challenge!
int
sfork(void)
{
  8012a0:	55                   	push   %ebp
  8012a1:	89 e5                	mov    %esp,%ebp
  8012a3:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  8012a6:	c7 44 24 08 d6 32 80 	movl   $0x8032d6,0x8(%esp)
  8012ad:	00 
  8012ae:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  8012b5:	00 
  8012b6:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  8012bd:	e8 ca ef ff ff       	call   80028c <_panic>

008012c2 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8012c2:	55                   	push   %ebp
  8012c3:	89 e5                	mov    %esp,%ebp
  8012c5:	57                   	push   %edi
  8012c6:	56                   	push   %esi
  8012c7:	53                   	push   %ebx
  8012c8:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  8012cb:	c7 04 24 2c 15 80 00 	movl   $0x80152c,(%esp)
  8012d2:	e8 6d 18 00 00       	call   802b44 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  8012d7:	ba 07 00 00 00       	mov    $0x7,%edx
  8012dc:	89 d0                	mov    %edx,%eax
  8012de:	cd 30                	int    $0x30
  8012e0:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  8012e3:	85 c0                	test   %eax,%eax
  8012e5:	79 20                	jns    801307 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  8012e7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8012eb:	c7 44 24 08 5c 33 80 	movl   $0x80335c,0x8(%esp)
  8012f2:	00 
  8012f3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8012fa:	00 
  8012fb:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801302:	e8 85 ef ff ff       	call   80028c <_panic>
    } else if (childId>0) {
  801307:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80130b:	0f 8e f3 01 00 00    	jle    801504 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801311:	c7 44 24 04 b4 2b 80 	movl   $0x802bb4,0x4(%esp)
  801318:	00 
  801319:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80131c:	89 04 24             	mov    %eax,(%esp)
  80131f:	e8 7c fc ff ff       	call   800fa0 <sys_env_set_pgfault_upcall>
  801324:	85 c0                	test   %eax,%eax
  801326:	74 20                	je     801348 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801328:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80132c:	c7 44 24 08 80 33 80 	movl   $0x803380,0x8(%esp)
  801333:	00 
  801334:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  80133b:	00 
  80133c:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801343:	e8 44 ef ff ff       	call   80028c <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801348:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80134f:	00 
  801350:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801357:	ee 
  801358:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80135b:	89 04 24             	mov    %eax,(%esp)
  80135e:	e8 13 fe ff ff       	call   801176 <sys_page_alloc>
  801363:	85 c0                	test   %eax,%eax
  801365:	79 20                	jns    801387 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801367:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80136b:	c7 44 24 08 b0 33 80 	movl   $0x8033b0,0x8(%esp)
  801372:	00 
  801373:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80137a:	00 
  80137b:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801382:	e8 05 ef ff ff       	call   80028c <_panic>
  801387:	be 00 00 80 00       	mov    $0x800000,%esi
  80138c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801391:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801396:	89 f0                	mov    %esi,%eax
  801398:	c1 e8 16             	shr    $0x16,%eax
  80139b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80139e:	a8 01                	test   $0x1,%al
  8013a0:	0f 84 13 01 00 00    	je     8014b9 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  8013a6:	89 f0                	mov    %esi,%eax
  8013a8:	c1 e8 0c             	shr    $0xc,%eax
  8013ab:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8013b2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8013b5:	25 07 0e 00 00       	and    $0xe07,%eax
  8013ba:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  8013bd:	e8 47 fe ff ff       	call   801209 <sys_getenvid>
  8013c2:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  8013c5:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  8013c9:	0f 84 ea 00 00 00    	je     8014b9 <fork+0x1f7>
  8013cf:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  8013d6:	0f 84 9d 00 00 00    	je     801479 <fork+0x1b7>
  8013dc:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  8013e3:	0f 85 90 00 00 00    	jne    801479 <fork+0x1b7>
    perm    &= (~PTE_W);
  8013e9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8013ec:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  8013ef:	80 cc 08             	or     $0x8,%ah
  8013f2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8013f5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8013f8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013fc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801400:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801403:	89 44 24 08          	mov    %eax,0x8(%esp)
  801407:	89 74 24 04          	mov    %esi,0x4(%esp)
  80140b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80140e:	89 04 24             	mov    %eax,(%esp)
  801411:	e8 02 fd ff ff       	call   801118 <sys_page_map>
  801416:	85 c0                	test   %eax,%eax
  801418:	79 1b                	jns    801435 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80141a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80141e:	89 74 24 08          	mov    %esi,0x8(%esp)
  801422:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801425:	89 44 24 04          	mov    %eax,0x4(%esp)
  801429:	c7 04 24 d8 33 80 00 	movl   $0x8033d8,(%esp)
  801430:	e8 1c ef ff ff       	call   800351 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801435:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801438:	89 44 24 10          	mov    %eax,0x10(%esp)
  80143c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80143f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801443:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801446:	89 44 24 08          	mov    %eax,0x8(%esp)
  80144a:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80144d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801451:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801454:	89 04 24             	mov    %eax,(%esp)
  801457:	e8 bc fc ff ff       	call   801118 <sys_page_map>
  80145c:	85 c0                	test   %eax,%eax
  80145e:	79 59                	jns    8014b9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801460:	89 44 24 08          	mov    %eax,0x8(%esp)
  801464:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801467:	89 44 24 04          	mov    %eax,0x4(%esp)
  80146b:	c7 04 24 18 34 80 00 	movl   $0x803418,(%esp)
  801472:	e8 da ee ff ff       	call   800351 <cprintf>
  801477:	eb 40                	jmp    8014b9 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801479:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80147c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801480:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801484:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801487:	89 44 24 08          	mov    %eax,0x8(%esp)
  80148b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80148f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801492:	89 04 24             	mov    %eax,(%esp)
  801495:	e8 7e fc ff ff       	call   801118 <sys_page_map>
  80149a:	85 c0                	test   %eax,%eax
  80149c:	79 1b                	jns    8014b9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80149e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014a2:	89 74 24 08          	mov    %esi,0x8(%esp)
  8014a6:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8014a9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014ad:	c7 04 24 d8 33 80 00 	movl   $0x8033d8,(%esp)
  8014b4:	e8 98 ee ff ff       	call   800351 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  8014b9:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8014bf:	89 de                	mov    %ebx,%esi
  8014c1:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8014c7:	0f 85 c9 fe ff ff    	jne    801396 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  8014cd:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8014d4:	00 
  8014d5:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8014d8:	89 04 24             	mov    %eax,(%esp)
  8014db:	e8 7c fb ff ff       	call   80105c <sys_env_set_status>
  8014e0:	85 c0                	test   %eax,%eax
  8014e2:	79 3d                	jns    801521 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  8014e4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014e8:	c7 44 24 08 4c 34 80 	movl   $0x80344c,0x8(%esp)
  8014ef:	00 
  8014f0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8014f7:	00 
  8014f8:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  8014ff:	e8 88 ed ff ff       	call   80028c <_panic>
    } else if (childId==0) {
  801504:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801508:	75 17                	jne    801521 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80150a:	e8 fa fc ff ff       	call   801209 <sys_getenvid>
  80150f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801514:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801517:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80151c:	a3 74 70 80 00       	mov    %eax,0x807074
    }
    return childId;
}
  801521:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801524:	83 c4 3c             	add    $0x3c,%esp
  801527:	5b                   	pop    %ebx
  801528:	5e                   	pop    %esi
  801529:	5f                   	pop    %edi
  80152a:	5d                   	pop    %ebp
  80152b:	c3                   	ret    

0080152c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80152c:	55                   	push   %ebp
  80152d:	89 e5                	mov    %esp,%ebp
  80152f:	57                   	push   %edi
  801530:	56                   	push   %esi
  801531:	53                   	push   %ebx
  801532:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801535:	8b 45 08             	mov    0x8(%ebp),%eax
  801538:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  80153a:	8b 50 04             	mov    0x4(%eax),%edx
  80153d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801540:	89 fe                	mov    %edi,%esi
  801542:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801548:	e8 bc fc ff ff       	call   801209 <sys_getenvid>
  80154d:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  80154f:	89 f2                	mov    %esi,%edx
  801551:	89 f0                	mov    %esi,%eax
  801553:	c1 e8 16             	shr    $0x16,%eax
  801556:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80155d:	a8 01                	test   $0x1,%al
  80155f:	74 3e                	je     80159f <pgfault+0x73>
  801561:	c1 ea 0c             	shr    $0xc,%edx
  801564:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80156b:	a8 01                	test   $0x1,%al
  80156d:	74 30                	je     80159f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80156f:	c1 ef 0c             	shr    $0xc,%edi
  801572:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801579:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80157f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801582:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801586:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80158d:	00 
  80158e:	89 1c 24             	mov    %ebx,(%esp)
  801591:	e8 e0 fb ff ff       	call   801176 <sys_page_alloc>
  801596:	85 c0                	test   %eax,%eax
  801598:	74 46                	je     8015e0 <pgfault+0xb4>
  80159a:	e9 cd 00 00 00       	jmp    80166c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80159f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8015a2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015a6:	8b 55 08             	mov    0x8(%ebp),%edx
  8015a9:	8b 42 28             	mov    0x28(%edx),%eax
  8015ac:	89 44 24 08          	mov    %eax,0x8(%esp)
  8015b0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8015b4:	c7 04 24 6c 34 80 00 	movl   $0x80346c,(%esp)
  8015bb:	e8 91 ed ff ff       	call   800351 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  8015c0:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8015c4:	c7 44 24 08 f7 32 80 	movl   $0x8032f7,0x8(%esp)
  8015cb:	00 
  8015cc:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8015d3:	00 
  8015d4:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  8015db:	e8 ac ec ff ff       	call   80028c <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  8015e0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  8015e7:	00 
  8015e8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8015ec:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8015f3:	e8 dd f5 ff ff       	call   800bd5 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8015f8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8015fc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801600:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801604:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80160b:	00 
  80160c:	89 1c 24             	mov    %ebx,(%esp)
  80160f:	e8 04 fb ff ff       	call   801118 <sys_page_map>
  801614:	85 c0                	test   %eax,%eax
  801616:	74 20                	je     801638 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801618:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80161c:	c7 44 24 08 09 33 80 	movl   $0x803309,0x8(%esp)
  801623:	00 
  801624:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  80162b:	00 
  80162c:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801633:	e8 54 ec ff ff       	call   80028c <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801638:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80163f:	00 
  801640:	89 1c 24             	mov    %ebx,(%esp)
  801643:	e8 72 fa ff ff       	call   8010ba <sys_page_unmap>
  801648:	85 c0                	test   %eax,%eax
  80164a:	74 40                	je     80168c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  80164c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801650:	c7 44 24 08 24 33 80 	movl   $0x803324,0x8(%esp)
  801657:	00 
  801658:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80165f:	00 
  801660:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801667:	e8 20 ec ff ff       	call   80028c <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80166c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801670:	c7 44 24 08 41 33 80 	movl   $0x803341,0x8(%esp)
  801677:	00 
  801678:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80167f:	00 
  801680:	c7 04 24 ec 32 80 00 	movl   $0x8032ec,(%esp)
  801687:	e8 00 ec ff ff       	call   80028c <_panic>
}
  80168c:	83 c4 3c             	add    $0x3c,%esp
  80168f:	5b                   	pop    %ebx
  801690:	5e                   	pop    %esi
  801691:	5f                   	pop    %edi
  801692:	5d                   	pop    %ebp
  801693:	c3                   	ret    
	...

008016a0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8016a0:	55                   	push   %ebp
  8016a1:	89 e5                	mov    %esp,%ebp
  8016a3:	57                   	push   %edi
  8016a4:	56                   	push   %esi
  8016a5:	53                   	push   %ebx
  8016a6:	83 ec 2c             	sub    $0x2c,%esp
  8016a9:	8b 75 08             	mov    0x8(%ebp),%esi
  8016ac:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8016af:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  8016b2:	85 db                	test   %ebx,%ebx
  8016b4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8016b9:	0f 45 c3             	cmovne %ebx,%eax
  8016bc:	8b 55 14             	mov    0x14(%ebp),%edx
  8016bf:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8016c3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8016c7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8016cb:	89 34 24             	mov    %esi,(%esp)
  8016ce:	e8 6d f8 ff ff       	call   800f40 <sys_ipc_try_send>
  8016d3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  8016d6:	75 0a                	jne    8016e2 <ipc_send+0x42>
      sys_yield();
  8016d8:	e8 f8 fa ff ff       	call   8011d5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  8016dd:	8d 76 00             	lea    0x0(%esi),%esi
  8016e0:	eb d0                	jmp    8016b2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  8016e2:	85 c0                	test   %eax,%eax
  8016e4:	79 24                	jns    80170a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  8016e6:	89 44 24 10          	mov    %eax,0x10(%esp)
  8016ea:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8016ee:	c7 44 24 08 98 34 80 	movl   $0x803498,0x8(%esp)
  8016f5:	00 
  8016f6:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  8016fd:	00 
  8016fe:	c7 04 24 bc 34 80 00 	movl   $0x8034bc,(%esp)
  801705:	e8 82 eb ff ff       	call   80028c <_panic>
    else
      return;
  }
}
  80170a:	83 c4 2c             	add    $0x2c,%esp
  80170d:	5b                   	pop    %ebx
  80170e:	5e                   	pop    %esi
  80170f:	5f                   	pop    %edi
  801710:	5d                   	pop    %ebp
  801711:	c3                   	ret    

00801712 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  801712:	55                   	push   %ebp
  801713:	89 e5                	mov    %esp,%ebp
  801715:	56                   	push   %esi
  801716:	53                   	push   %ebx
  801717:	83 ec 10             	sub    $0x10,%esp
  80171a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80171d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801720:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  801723:	85 c0                	test   %eax,%eax
  801725:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80172a:	0f 44 c2             	cmove  %edx,%eax
  80172d:	89 04 24             	mov    %eax,(%esp)
  801730:	e8 ae f7 ff ff       	call   800ee3 <sys_ipc_recv>
  801735:	85 c0                	test   %eax,%eax
  801737:	78 24                	js     80175d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  801739:	85 db                	test   %ebx,%ebx
  80173b:	74 0a                	je     801747 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  80173d:	a1 74 70 80 00       	mov    0x807074,%eax
  801742:	8b 40 74             	mov    0x74(%eax),%eax
  801745:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  801747:	85 f6                	test   %esi,%esi
  801749:	74 0a                	je     801755 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  80174b:	a1 74 70 80 00       	mov    0x807074,%eax
  801750:	8b 40 78             	mov    0x78(%eax),%eax
  801753:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  801755:	a1 74 70 80 00       	mov    0x807074,%eax
  80175a:	8b 40 70             	mov    0x70(%eax),%eax
}
  80175d:	83 c4 10             	add    $0x10,%esp
  801760:	5b                   	pop    %ebx
  801761:	5e                   	pop    %esi
  801762:	5d                   	pop    %ebp
  801763:	c3                   	ret    
	...

00801770 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801770:	55                   	push   %ebp
  801771:	89 e5                	mov    %esp,%ebp
  801773:	8b 45 08             	mov    0x8(%ebp),%eax
  801776:	05 00 00 00 30       	add    $0x30000000,%eax
  80177b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80177e:	5d                   	pop    %ebp
  80177f:	c3                   	ret    

00801780 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801780:	55                   	push   %ebp
  801781:	89 e5                	mov    %esp,%ebp
  801783:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801786:	8b 45 08             	mov    0x8(%ebp),%eax
  801789:	89 04 24             	mov    %eax,(%esp)
  80178c:	e8 df ff ff ff       	call   801770 <fd2num>
  801791:	05 20 00 0d 00       	add    $0xd0020,%eax
  801796:	c1 e0 0c             	shl    $0xc,%eax
}
  801799:	c9                   	leave  
  80179a:	c3                   	ret    

0080179b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80179b:	55                   	push   %ebp
  80179c:	89 e5                	mov    %esp,%ebp
  80179e:	57                   	push   %edi
  80179f:	56                   	push   %esi
  8017a0:	53                   	push   %ebx
  8017a1:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  8017a4:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  8017a9:	a8 01                	test   $0x1,%al
  8017ab:	74 36                	je     8017e3 <fd_alloc+0x48>
  8017ad:	a1 00 00 74 ef       	mov    0xef740000,%eax
  8017b2:	a8 01                	test   $0x1,%al
  8017b4:	74 2d                	je     8017e3 <fd_alloc+0x48>
  8017b6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  8017bb:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8017c0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8017c5:	89 c3                	mov    %eax,%ebx
  8017c7:	89 c2                	mov    %eax,%edx
  8017c9:	c1 ea 16             	shr    $0x16,%edx
  8017cc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8017cf:	f6 c2 01             	test   $0x1,%dl
  8017d2:	74 14                	je     8017e8 <fd_alloc+0x4d>
  8017d4:	89 c2                	mov    %eax,%edx
  8017d6:	c1 ea 0c             	shr    $0xc,%edx
  8017d9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8017dc:	f6 c2 01             	test   $0x1,%dl
  8017df:	75 10                	jne    8017f1 <fd_alloc+0x56>
  8017e1:	eb 05                	jmp    8017e8 <fd_alloc+0x4d>
  8017e3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8017e8:	89 1f                	mov    %ebx,(%edi)
  8017ea:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8017ef:	eb 17                	jmp    801808 <fd_alloc+0x6d>
  8017f1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8017f6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8017fb:	75 c8                	jne    8017c5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8017fd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801803:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801808:	5b                   	pop    %ebx
  801809:	5e                   	pop    %esi
  80180a:	5f                   	pop    %edi
  80180b:	5d                   	pop    %ebp
  80180c:	c3                   	ret    

0080180d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80180d:	55                   	push   %ebp
  80180e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801810:	8b 45 08             	mov    0x8(%ebp),%eax
  801813:	83 f8 1f             	cmp    $0x1f,%eax
  801816:	77 36                	ja     80184e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801818:	05 00 00 0d 00       	add    $0xd0000,%eax
  80181d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801820:	89 c2                	mov    %eax,%edx
  801822:	c1 ea 16             	shr    $0x16,%edx
  801825:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80182c:	f6 c2 01             	test   $0x1,%dl
  80182f:	74 1d                	je     80184e <fd_lookup+0x41>
  801831:	89 c2                	mov    %eax,%edx
  801833:	c1 ea 0c             	shr    $0xc,%edx
  801836:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80183d:	f6 c2 01             	test   $0x1,%dl
  801840:	74 0c                	je     80184e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801842:	8b 55 0c             	mov    0xc(%ebp),%edx
  801845:	89 02                	mov    %eax,(%edx)
  801847:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80184c:	eb 05                	jmp    801853 <fd_lookup+0x46>
  80184e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801853:	5d                   	pop    %ebp
  801854:	c3                   	ret    

00801855 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801855:	55                   	push   %ebp
  801856:	89 e5                	mov    %esp,%ebp
  801858:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80185b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80185e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801862:	8b 45 08             	mov    0x8(%ebp),%eax
  801865:	89 04 24             	mov    %eax,(%esp)
  801868:	e8 a0 ff ff ff       	call   80180d <fd_lookup>
  80186d:	85 c0                	test   %eax,%eax
  80186f:	78 0e                	js     80187f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801871:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801874:	8b 55 0c             	mov    0xc(%ebp),%edx
  801877:	89 50 04             	mov    %edx,0x4(%eax)
  80187a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80187f:	c9                   	leave  
  801880:	c3                   	ret    

00801881 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801881:	55                   	push   %ebp
  801882:	89 e5                	mov    %esp,%ebp
  801884:	56                   	push   %esi
  801885:	53                   	push   %ebx
  801886:	83 ec 10             	sub    $0x10,%esp
  801889:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80188c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80188f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801894:	b8 04 70 80 00       	mov    $0x807004,%eax
  801899:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80189f:	75 11                	jne    8018b2 <dev_lookup+0x31>
  8018a1:	eb 04                	jmp    8018a7 <dev_lookup+0x26>
  8018a3:	39 08                	cmp    %ecx,(%eax)
  8018a5:	75 10                	jne    8018b7 <dev_lookup+0x36>
			*dev = devtab[i];
  8018a7:	89 03                	mov    %eax,(%ebx)
  8018a9:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8018ae:	66 90                	xchg   %ax,%ax
  8018b0:	eb 36                	jmp    8018e8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  8018b2:	be 44 35 80 00       	mov    $0x803544,%esi
  8018b7:	83 c2 01             	add    $0x1,%edx
  8018ba:	8b 04 96             	mov    (%esi,%edx,4),%eax
  8018bd:	85 c0                	test   %eax,%eax
  8018bf:	75 e2                	jne    8018a3 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8018c1:	a1 74 70 80 00       	mov    0x807074,%eax
  8018c6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8018c9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8018cd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018d1:	c7 04 24 c8 34 80 00 	movl   $0x8034c8,(%esp)
  8018d8:	e8 74 ea ff ff       	call   800351 <cprintf>
	*dev = 0;
  8018dd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8018e3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8018e8:	83 c4 10             	add    $0x10,%esp
  8018eb:	5b                   	pop    %ebx
  8018ec:	5e                   	pop    %esi
  8018ed:	5d                   	pop    %ebp
  8018ee:	c3                   	ret    

008018ef <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8018ef:	55                   	push   %ebp
  8018f0:	89 e5                	mov    %esp,%ebp
  8018f2:	53                   	push   %ebx
  8018f3:	83 ec 24             	sub    $0x24,%esp
  8018f6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8018f9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8018fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801900:	8b 45 08             	mov    0x8(%ebp),%eax
  801903:	89 04 24             	mov    %eax,(%esp)
  801906:	e8 02 ff ff ff       	call   80180d <fd_lookup>
  80190b:	85 c0                	test   %eax,%eax
  80190d:	78 53                	js     801962 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80190f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801912:	89 44 24 04          	mov    %eax,0x4(%esp)
  801916:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801919:	8b 00                	mov    (%eax),%eax
  80191b:	89 04 24             	mov    %eax,(%esp)
  80191e:	e8 5e ff ff ff       	call   801881 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801923:	85 c0                	test   %eax,%eax
  801925:	78 3b                	js     801962 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801927:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80192c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80192f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801933:	74 2d                	je     801962 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801935:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801938:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80193f:	00 00 00 
	stat->st_isdir = 0;
  801942:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801949:	00 00 00 
	stat->st_dev = dev;
  80194c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80194f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801955:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801959:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80195c:	89 14 24             	mov    %edx,(%esp)
  80195f:	ff 50 14             	call   *0x14(%eax)
}
  801962:	83 c4 24             	add    $0x24,%esp
  801965:	5b                   	pop    %ebx
  801966:	5d                   	pop    %ebp
  801967:	c3                   	ret    

00801968 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801968:	55                   	push   %ebp
  801969:	89 e5                	mov    %esp,%ebp
  80196b:	53                   	push   %ebx
  80196c:	83 ec 24             	sub    $0x24,%esp
  80196f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801972:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801975:	89 44 24 04          	mov    %eax,0x4(%esp)
  801979:	89 1c 24             	mov    %ebx,(%esp)
  80197c:	e8 8c fe ff ff       	call   80180d <fd_lookup>
  801981:	85 c0                	test   %eax,%eax
  801983:	78 5f                	js     8019e4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801985:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801988:	89 44 24 04          	mov    %eax,0x4(%esp)
  80198c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80198f:	8b 00                	mov    (%eax),%eax
  801991:	89 04 24             	mov    %eax,(%esp)
  801994:	e8 e8 fe ff ff       	call   801881 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801999:	85 c0                	test   %eax,%eax
  80199b:	78 47                	js     8019e4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80199d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8019a0:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8019a4:	75 23                	jne    8019c9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  8019a6:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  8019ab:	8b 40 4c             	mov    0x4c(%eax),%eax
  8019ae:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019b6:	c7 04 24 e8 34 80 00 	movl   $0x8034e8,(%esp)
  8019bd:	e8 8f e9 ff ff       	call   800351 <cprintf>
  8019c2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8019c7:	eb 1b                	jmp    8019e4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8019c9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8019cc:	8b 48 18             	mov    0x18(%eax),%ecx
  8019cf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8019d4:	85 c9                	test   %ecx,%ecx
  8019d6:	74 0c                	je     8019e4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8019d8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8019db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019df:	89 14 24             	mov    %edx,(%esp)
  8019e2:	ff d1                	call   *%ecx
}
  8019e4:	83 c4 24             	add    $0x24,%esp
  8019e7:	5b                   	pop    %ebx
  8019e8:	5d                   	pop    %ebp
  8019e9:	c3                   	ret    

008019ea <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8019ea:	55                   	push   %ebp
  8019eb:	89 e5                	mov    %esp,%ebp
  8019ed:	53                   	push   %ebx
  8019ee:	83 ec 24             	sub    $0x24,%esp
  8019f1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8019f4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8019f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019fb:	89 1c 24             	mov    %ebx,(%esp)
  8019fe:	e8 0a fe ff ff       	call   80180d <fd_lookup>
  801a03:	85 c0                	test   %eax,%eax
  801a05:	78 66                	js     801a6d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a07:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a0a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a0e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a11:	8b 00                	mov    (%eax),%eax
  801a13:	89 04 24             	mov    %eax,(%esp)
  801a16:	e8 66 fe ff ff       	call   801881 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a1b:	85 c0                	test   %eax,%eax
  801a1d:	78 4e                	js     801a6d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801a1f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801a22:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801a26:	75 23                	jne    801a4b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801a28:	a1 74 70 80 00       	mov    0x807074,%eax
  801a2d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801a30:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801a34:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a38:	c7 04 24 09 35 80 00 	movl   $0x803509,(%esp)
  801a3f:	e8 0d e9 ff ff       	call   800351 <cprintf>
  801a44:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801a49:	eb 22                	jmp    801a6d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801a4b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a4e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801a51:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a56:	85 c9                	test   %ecx,%ecx
  801a58:	74 13                	je     801a6d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801a5a:	8b 45 10             	mov    0x10(%ebp),%eax
  801a5d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a61:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a64:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a68:	89 14 24             	mov    %edx,(%esp)
  801a6b:	ff d1                	call   *%ecx
}
  801a6d:	83 c4 24             	add    $0x24,%esp
  801a70:	5b                   	pop    %ebx
  801a71:	5d                   	pop    %ebp
  801a72:	c3                   	ret    

00801a73 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801a73:	55                   	push   %ebp
  801a74:	89 e5                	mov    %esp,%ebp
  801a76:	57                   	push   %edi
  801a77:	56                   	push   %esi
  801a78:	53                   	push   %ebx
  801a79:	83 ec 2c             	sub    $0x2c,%esp
  801a7c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801a7f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a82:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801a85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a89:	89 1c 24             	mov    %ebx,(%esp)
  801a8c:	e8 7c fd ff ff       	call   80180d <fd_lookup>
  801a91:	85 c0                	test   %eax,%eax
  801a93:	0f 88 b0 00 00 00    	js     801b49 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a99:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801a9c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801aa0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801aa3:	8b 00                	mov    (%eax),%eax
  801aa5:	89 04 24             	mov    %eax,(%esp)
  801aa8:	e8 d4 fd ff ff       	call   801881 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801aad:	85 c0                	test   %eax,%eax
  801aaf:	0f 88 94 00 00 00    	js     801b49 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801ab5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801ab8:	8b 40 08             	mov    0x8(%eax),%eax
  801abb:	83 e0 03             	and    $0x3,%eax
  801abe:	83 f8 01             	cmp    $0x1,%eax
  801ac1:	75 23                	jne    801ae6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801ac3:	a1 74 70 80 00       	mov    0x807074,%eax
  801ac8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801acb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801acf:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ad3:	c7 04 24 26 35 80 00 	movl   $0x803526,(%esp)
  801ada:	e8 72 e8 ff ff       	call   800351 <cprintf>
  801adf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801ae4:	eb 63                	jmp    801b49 <read+0xd6>
	}
	if (!dev->dev_read)
  801ae6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801aeb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801aee:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801af2:	74 55                	je     801b49 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801af4:	ba 00 00 00 00       	mov    $0x0,%edx
  801af9:	bb 00 00 00 00       	mov    $0x0,%ebx
  801afe:	b8 00 00 00 00       	mov    $0x0,%eax
  801b03:	85 f6                	test   %esi,%esi
  801b05:	74 42                	je     801b49 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801b07:	bf 00 10 00 00       	mov    $0x1000,%edi
  801b0c:	89 f0                	mov    %esi,%eax
  801b0e:	29 d0                	sub    %edx,%eax
  801b10:	89 c1                	mov    %eax,%ecx
  801b12:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801b18:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801b1d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801b20:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801b24:	03 55 0c             	add    0xc(%ebp),%edx
  801b27:	89 54 24 04          	mov    %edx,0x4(%esp)
  801b2b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801b2e:	89 04 24             	mov    %eax,(%esp)
  801b31:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b34:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801b37:	85 c0                	test   %eax,%eax
  801b39:	78 0e                	js     801b49 <read+0xd6>
			return m;
		if (m == 0)
  801b3b:	85 c0                	test   %eax,%eax
  801b3d:	74 08                	je     801b47 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801b3f:	01 c3                	add    %eax,%ebx
  801b41:	89 da                	mov    %ebx,%edx
  801b43:	39 f3                	cmp    %esi,%ebx
  801b45:	72 c5                	jb     801b0c <read+0x99>
  801b47:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801b49:	83 c4 2c             	add    $0x2c,%esp
  801b4c:	5b                   	pop    %ebx
  801b4d:	5e                   	pop    %esi
  801b4e:	5f                   	pop    %edi
  801b4f:	5d                   	pop    %ebp
  801b50:	c3                   	ret    

00801b51 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801b51:	55                   	push   %ebp
  801b52:	89 e5                	mov    %esp,%ebp
  801b54:	57                   	push   %edi
  801b55:	56                   	push   %esi
  801b56:	53                   	push   %ebx
  801b57:	83 ec 1c             	sub    $0x1c,%esp
  801b5a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801b5d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801b60:	ba 00 00 00 00       	mov    $0x0,%edx
  801b65:	bb 00 00 00 00       	mov    $0x0,%ebx
  801b6a:	b8 00 00 00 00       	mov    $0x0,%eax
  801b6f:	85 f6                	test   %esi,%esi
  801b71:	74 29                	je     801b9c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801b73:	89 f0                	mov    %esi,%eax
  801b75:	29 d0                	sub    %edx,%eax
  801b77:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b7b:	03 55 0c             	add    0xc(%ebp),%edx
  801b7e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801b82:	89 3c 24             	mov    %edi,(%esp)
  801b85:	e8 e9 fe ff ff       	call   801a73 <read>
		if (m < 0)
  801b8a:	85 c0                	test   %eax,%eax
  801b8c:	78 0e                	js     801b9c <readn+0x4b>
			return m;
		if (m == 0)
  801b8e:	85 c0                	test   %eax,%eax
  801b90:	74 08                	je     801b9a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801b92:	01 c3                	add    %eax,%ebx
  801b94:	89 da                	mov    %ebx,%edx
  801b96:	39 f3                	cmp    %esi,%ebx
  801b98:	72 d9                	jb     801b73 <readn+0x22>
  801b9a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801b9c:	83 c4 1c             	add    $0x1c,%esp
  801b9f:	5b                   	pop    %ebx
  801ba0:	5e                   	pop    %esi
  801ba1:	5f                   	pop    %edi
  801ba2:	5d                   	pop    %ebp
  801ba3:	c3                   	ret    

00801ba4 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801ba4:	55                   	push   %ebp
  801ba5:	89 e5                	mov    %esp,%ebp
  801ba7:	83 ec 28             	sub    $0x28,%esp
  801baa:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801bad:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801bb0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801bb3:	89 34 24             	mov    %esi,(%esp)
  801bb6:	e8 b5 fb ff ff       	call   801770 <fd2num>
  801bbb:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801bbe:	89 54 24 04          	mov    %edx,0x4(%esp)
  801bc2:	89 04 24             	mov    %eax,(%esp)
  801bc5:	e8 43 fc ff ff       	call   80180d <fd_lookup>
  801bca:	89 c3                	mov    %eax,%ebx
  801bcc:	85 c0                	test   %eax,%eax
  801bce:	78 05                	js     801bd5 <fd_close+0x31>
  801bd0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801bd3:	74 0e                	je     801be3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801bd5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801bd9:	b8 00 00 00 00       	mov    $0x0,%eax
  801bde:	0f 44 d8             	cmove  %eax,%ebx
  801be1:	eb 3d                	jmp    801c20 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801be3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801be6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bea:	8b 06                	mov    (%esi),%eax
  801bec:	89 04 24             	mov    %eax,(%esp)
  801bef:	e8 8d fc ff ff       	call   801881 <dev_lookup>
  801bf4:	89 c3                	mov    %eax,%ebx
  801bf6:	85 c0                	test   %eax,%eax
  801bf8:	78 16                	js     801c10 <fd_close+0x6c>
		if (dev->dev_close)
  801bfa:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801bfd:	8b 40 10             	mov    0x10(%eax),%eax
  801c00:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c05:	85 c0                	test   %eax,%eax
  801c07:	74 07                	je     801c10 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801c09:	89 34 24             	mov    %esi,(%esp)
  801c0c:	ff d0                	call   *%eax
  801c0e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801c10:	89 74 24 04          	mov    %esi,0x4(%esp)
  801c14:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c1b:	e8 9a f4 ff ff       	call   8010ba <sys_page_unmap>
	return r;
}
  801c20:	89 d8                	mov    %ebx,%eax
  801c22:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801c25:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801c28:	89 ec                	mov    %ebp,%esp
  801c2a:	5d                   	pop    %ebp
  801c2b:	c3                   	ret    

00801c2c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801c2c:	55                   	push   %ebp
  801c2d:	89 e5                	mov    %esp,%ebp
  801c2f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801c32:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801c35:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c39:	8b 45 08             	mov    0x8(%ebp),%eax
  801c3c:	89 04 24             	mov    %eax,(%esp)
  801c3f:	e8 c9 fb ff ff       	call   80180d <fd_lookup>
  801c44:	85 c0                	test   %eax,%eax
  801c46:	78 13                	js     801c5b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801c48:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801c4f:	00 
  801c50:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c53:	89 04 24             	mov    %eax,(%esp)
  801c56:	e8 49 ff ff ff       	call   801ba4 <fd_close>
}
  801c5b:	c9                   	leave  
  801c5c:	c3                   	ret    

00801c5d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801c5d:	55                   	push   %ebp
  801c5e:	89 e5                	mov    %esp,%ebp
  801c60:	83 ec 18             	sub    $0x18,%esp
  801c63:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801c66:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801c69:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801c70:	00 
  801c71:	8b 45 08             	mov    0x8(%ebp),%eax
  801c74:	89 04 24             	mov    %eax,(%esp)
  801c77:	e8 80 03 00 00       	call   801ffc <open>
  801c7c:	89 c3                	mov    %eax,%ebx
  801c7e:	85 c0                	test   %eax,%eax
  801c80:	78 1b                	js     801c9d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801c82:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c89:	89 1c 24             	mov    %ebx,(%esp)
  801c8c:	e8 5e fc ff ff       	call   8018ef <fstat>
  801c91:	89 c6                	mov    %eax,%esi
	close(fd);
  801c93:	89 1c 24             	mov    %ebx,(%esp)
  801c96:	e8 91 ff ff ff       	call   801c2c <close>
  801c9b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801c9d:	89 d8                	mov    %ebx,%eax
  801c9f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801ca2:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801ca5:	89 ec                	mov    %ebp,%esp
  801ca7:	5d                   	pop    %ebp
  801ca8:	c3                   	ret    

00801ca9 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801ca9:	55                   	push   %ebp
  801caa:	89 e5                	mov    %esp,%ebp
  801cac:	53                   	push   %ebx
  801cad:	83 ec 14             	sub    $0x14,%esp
  801cb0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801cb5:	89 1c 24             	mov    %ebx,(%esp)
  801cb8:	e8 6f ff ff ff       	call   801c2c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801cbd:	83 c3 01             	add    $0x1,%ebx
  801cc0:	83 fb 20             	cmp    $0x20,%ebx
  801cc3:	75 f0                	jne    801cb5 <close_all+0xc>
		close(i);
}
  801cc5:	83 c4 14             	add    $0x14,%esp
  801cc8:	5b                   	pop    %ebx
  801cc9:	5d                   	pop    %ebp
  801cca:	c3                   	ret    

00801ccb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801ccb:	55                   	push   %ebp
  801ccc:	89 e5                	mov    %esp,%ebp
  801cce:	83 ec 58             	sub    $0x58,%esp
  801cd1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801cd4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801cd7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801cda:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801cdd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801ce0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ce4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ce7:	89 04 24             	mov    %eax,(%esp)
  801cea:	e8 1e fb ff ff       	call   80180d <fd_lookup>
  801cef:	89 c3                	mov    %eax,%ebx
  801cf1:	85 c0                	test   %eax,%eax
  801cf3:	0f 88 e0 00 00 00    	js     801dd9 <dup+0x10e>
		return r;
	close(newfdnum);
  801cf9:	89 3c 24             	mov    %edi,(%esp)
  801cfc:	e8 2b ff ff ff       	call   801c2c <close>

	newfd = INDEX2FD(newfdnum);
  801d01:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801d07:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801d0a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801d0d:	89 04 24             	mov    %eax,(%esp)
  801d10:	e8 6b fa ff ff       	call   801780 <fd2data>
  801d15:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801d17:	89 34 24             	mov    %esi,(%esp)
  801d1a:	e8 61 fa ff ff       	call   801780 <fd2data>
  801d1f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801d22:	89 da                	mov    %ebx,%edx
  801d24:	89 d8                	mov    %ebx,%eax
  801d26:	c1 e8 16             	shr    $0x16,%eax
  801d29:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801d30:	a8 01                	test   $0x1,%al
  801d32:	74 43                	je     801d77 <dup+0xac>
  801d34:	c1 ea 0c             	shr    $0xc,%edx
  801d37:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d3e:	a8 01                	test   $0x1,%al
  801d40:	74 35                	je     801d77 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801d42:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d49:	25 07 0e 00 00       	and    $0xe07,%eax
  801d4e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801d52:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801d55:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801d59:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801d60:	00 
  801d61:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d65:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d6c:	e8 a7 f3 ff ff       	call   801118 <sys_page_map>
  801d71:	89 c3                	mov    %eax,%ebx
  801d73:	85 c0                	test   %eax,%eax
  801d75:	78 3f                	js     801db6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801d77:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801d7a:	89 c2                	mov    %eax,%edx
  801d7c:	c1 ea 0c             	shr    $0xc,%edx
  801d7f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801d86:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801d8c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801d90:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801d94:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801d9b:	00 
  801d9c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801da0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801da7:	e8 6c f3 ff ff       	call   801118 <sys_page_map>
  801dac:	89 c3                	mov    %eax,%ebx
  801dae:	85 c0                	test   %eax,%eax
  801db0:	78 04                	js     801db6 <dup+0xeb>
  801db2:	89 fb                	mov    %edi,%ebx
  801db4:	eb 23                	jmp    801dd9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801db6:	89 74 24 04          	mov    %esi,0x4(%esp)
  801dba:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801dc1:	e8 f4 f2 ff ff       	call   8010ba <sys_page_unmap>
	sys_page_unmap(0, nva);
  801dc6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801dc9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dcd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801dd4:	e8 e1 f2 ff ff       	call   8010ba <sys_page_unmap>
	return r;
}
  801dd9:	89 d8                	mov    %ebx,%eax
  801ddb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801dde:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801de1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801de4:	89 ec                	mov    %ebp,%esp
  801de6:	5d                   	pop    %ebp
  801de7:	c3                   	ret    

00801de8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801de8:	55                   	push   %ebp
  801de9:	89 e5                	mov    %esp,%ebp
  801deb:	53                   	push   %ebx
  801dec:	83 ec 14             	sub    $0x14,%esp
  801def:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801df1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801df7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801dfe:	00 
  801dff:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801e06:	00 
  801e07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e0b:	89 14 24             	mov    %edx,(%esp)
  801e0e:	e8 8d f8 ff ff       	call   8016a0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801e13:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801e1a:	00 
  801e1b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e1f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e26:	e8 e7 f8 ff ff       	call   801712 <ipc_recv>
}
  801e2b:	83 c4 14             	add    $0x14,%esp
  801e2e:	5b                   	pop    %ebx
  801e2f:	5d                   	pop    %ebp
  801e30:	c3                   	ret    

00801e31 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801e31:	55                   	push   %ebp
  801e32:	89 e5                	mov    %esp,%ebp
  801e34:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801e37:	8b 45 08             	mov    0x8(%ebp),%eax
  801e3a:	8b 40 0c             	mov    0xc(%eax),%eax
  801e3d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801e42:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e45:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801e4a:	ba 00 00 00 00       	mov    $0x0,%edx
  801e4f:	b8 02 00 00 00       	mov    $0x2,%eax
  801e54:	e8 8f ff ff ff       	call   801de8 <fsipc>
}
  801e59:	c9                   	leave  
  801e5a:	c3                   	ret    

00801e5b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801e5b:	55                   	push   %ebp
  801e5c:	89 e5                	mov    %esp,%ebp
  801e5e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801e61:	8b 45 08             	mov    0x8(%ebp),%eax
  801e64:	8b 40 0c             	mov    0xc(%eax),%eax
  801e67:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801e6c:	ba 00 00 00 00       	mov    $0x0,%edx
  801e71:	b8 06 00 00 00       	mov    $0x6,%eax
  801e76:	e8 6d ff ff ff       	call   801de8 <fsipc>
}
  801e7b:	c9                   	leave  
  801e7c:	c3                   	ret    

00801e7d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801e7d:	55                   	push   %ebp
  801e7e:	89 e5                	mov    %esp,%ebp
  801e80:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801e83:	ba 00 00 00 00       	mov    $0x0,%edx
  801e88:	b8 08 00 00 00       	mov    $0x8,%eax
  801e8d:	e8 56 ff ff ff       	call   801de8 <fsipc>
}
  801e92:	c9                   	leave  
  801e93:	c3                   	ret    

00801e94 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801e94:	55                   	push   %ebp
  801e95:	89 e5                	mov    %esp,%ebp
  801e97:	53                   	push   %ebx
  801e98:	83 ec 14             	sub    $0x14,%esp
  801e9b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801e9e:	8b 45 08             	mov    0x8(%ebp),%eax
  801ea1:	8b 40 0c             	mov    0xc(%eax),%eax
  801ea4:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801ea9:	ba 00 00 00 00       	mov    $0x0,%edx
  801eae:	b8 05 00 00 00       	mov    $0x5,%eax
  801eb3:	e8 30 ff ff ff       	call   801de8 <fsipc>
  801eb8:	85 c0                	test   %eax,%eax
  801eba:	78 2b                	js     801ee7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801ebc:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801ec3:	00 
  801ec4:	89 1c 24             	mov    %ebx,(%esp)
  801ec7:	e8 4e eb ff ff       	call   800a1a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801ecc:	a1 80 40 80 00       	mov    0x804080,%eax
  801ed1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801ed7:	a1 84 40 80 00       	mov    0x804084,%eax
  801edc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801ee2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801ee7:	83 c4 14             	add    $0x14,%esp
  801eea:	5b                   	pop    %ebx
  801eeb:	5d                   	pop    %ebp
  801eec:	c3                   	ret    

00801eed <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801eed:	55                   	push   %ebp
  801eee:	89 e5                	mov    %esp,%ebp
  801ef0:	53                   	push   %ebx
  801ef1:	83 ec 14             	sub    $0x14,%esp
  801ef4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ef7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801efa:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801efd:	85 c0                	test   %eax,%eax
  801eff:	74 44                	je     801f45 <devfile_write+0x58>
  801f01:	85 d2                	test   %edx,%edx
  801f03:	74 40                	je     801f45 <devfile_write+0x58>
  801f05:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801f0b:	77 38                	ja     801f45 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801f0d:	8b 40 0c             	mov    0xc(%eax),%eax
  801f10:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801f15:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801f1b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801f1f:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f23:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801f2a:	e8 a6 ec ff ff       	call   800bd5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801f2f:	ba 00 00 00 00       	mov    $0x0,%edx
  801f34:	b8 04 00 00 00       	mov    $0x4,%eax
  801f39:	e8 aa fe ff ff       	call   801de8 <fsipc>
        return r;
    return n;
  801f3e:	85 c0                	test   %eax,%eax
  801f40:	0f 49 c3             	cmovns %ebx,%eax
  801f43:	eb 05                	jmp    801f4a <devfile_write+0x5d>
  801f45:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801f4a:	83 c4 14             	add    $0x14,%esp
  801f4d:	5b                   	pop    %ebx
  801f4e:	5d                   	pop    %ebp
  801f4f:	c3                   	ret    

00801f50 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801f50:	55                   	push   %ebp
  801f51:	89 e5                	mov    %esp,%ebp
  801f53:	83 ec 18             	sub    $0x18,%esp
  801f56:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801f59:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801f5c:	8b 45 08             	mov    0x8(%ebp),%eax
  801f5f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801f62:	85 c0                	test   %eax,%eax
  801f64:	74 04                	je     801f6a <devfile_read+0x1a>
  801f66:	85 f6                	test   %esi,%esi
  801f68:	75 07                	jne    801f71 <devfile_read+0x21>
  801f6a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801f6f:	eb 39                	jmp    801faa <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801f71:	8b 40 0c             	mov    0xc(%eax),%eax
  801f74:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801f79:	8b 45 10             	mov    0x10(%ebp),%eax
  801f7c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801f81:	ba 00 00 00 00       	mov    $0x0,%edx
  801f86:	b8 03 00 00 00       	mov    $0x3,%eax
  801f8b:	e8 58 fe ff ff       	call   801de8 <fsipc>
  801f90:	89 c3                	mov    %eax,%ebx
  801f92:	85 c0                	test   %eax,%eax
  801f94:	78 14                	js     801faa <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801f96:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f9a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801fa1:	00 
  801fa2:	89 34 24             	mov    %esi,(%esp)
  801fa5:	e8 2b ec ff ff       	call   800bd5 <memmove>
  return r;
}
  801faa:	89 d8                	mov    %ebx,%eax
  801fac:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801faf:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801fb2:	89 ec                	mov    %ebp,%esp
  801fb4:	5d                   	pop    %ebp
  801fb5:	c3                   	ret    

00801fb6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801fb6:	55                   	push   %ebp
  801fb7:	89 e5                	mov    %esp,%ebp
  801fb9:	53                   	push   %ebx
  801fba:	83 ec 14             	sub    $0x14,%esp
  801fbd:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801fc0:	89 1c 24             	mov    %ebx,(%esp)
  801fc3:	e8 08 ea ff ff       	call   8009d0 <strlen>
  801fc8:	89 c2                	mov    %eax,%edx
  801fca:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801fcf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801fd5:	7f 1f                	jg     801ff6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801fd7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801fdb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801fe2:	e8 33 ea ff ff       	call   800a1a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801fe7:	ba 00 00 00 00       	mov    $0x0,%edx
  801fec:	b8 07 00 00 00       	mov    $0x7,%eax
  801ff1:	e8 f2 fd ff ff       	call   801de8 <fsipc>
}
  801ff6:	83 c4 14             	add    $0x14,%esp
  801ff9:	5b                   	pop    %ebx
  801ffa:	5d                   	pop    %ebp
  801ffb:	c3                   	ret    

00801ffc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801ffc:	55                   	push   %ebp
  801ffd:	89 e5                	mov    %esp,%ebp
  801fff:	83 ec 28             	sub    $0x28,%esp
  802002:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802005:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802008:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  80200b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  802010:	85 f6                	test   %esi,%esi
  802012:	74 65                	je     802079 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  802014:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  80201b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80201e:	89 04 24             	mov    %eax,(%esp)
  802021:	e8 75 f7 ff ff       	call   80179b <fd_alloc>
  802026:	89 c3                	mov    %eax,%ebx
  802028:	85 c0                	test   %eax,%eax
  80202a:	78 4d                	js     802079 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80202c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802030:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802037:	e8 de e9 ff ff       	call   800a1a <strcpy>
	fsipcbuf.open.req_omode = mode;
  80203c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80203f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802044:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802047:	b8 01 00 00 00       	mov    $0x1,%eax
  80204c:	e8 97 fd ff ff       	call   801de8 <fsipc>
  802051:	89 c3                	mov    %eax,%ebx
  802053:	85 c0                	test   %eax,%eax
  802055:	79 15                	jns    80206c <open+0x70>
    fd_close(f, 0);
  802057:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80205e:	00 
  80205f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802062:	89 04 24             	mov    %eax,(%esp)
  802065:	e8 3a fb ff ff       	call   801ba4 <fd_close>
    return r;
  80206a:	eb 0d                	jmp    802079 <open+0x7d>
  }
  return fd2num(f);
  80206c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80206f:	89 04 24             	mov    %eax,(%esp)
  802072:	e8 f9 f6 ff ff       	call   801770 <fd2num>
  802077:	89 c3                	mov    %eax,%ebx
}
  802079:	89 d8                	mov    %ebx,%eax
  80207b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80207e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802081:	89 ec                	mov    %ebp,%esp
  802083:	5d                   	pop    %ebp
  802084:	c3                   	ret    
  802085:	00 00                	add    %al,(%eax)
	...

00802088 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802088:	55                   	push   %ebp
  802089:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  80208b:	8b 45 08             	mov    0x8(%ebp),%eax
  80208e:	89 c2                	mov    %eax,%edx
  802090:	c1 ea 16             	shr    $0x16,%edx
  802093:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80209a:	f6 c2 01             	test   $0x1,%dl
  80209d:	74 26                	je     8020c5 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  80209f:	c1 e8 0c             	shr    $0xc,%eax
  8020a2:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8020a9:	a8 01                	test   $0x1,%al
  8020ab:	74 18                	je     8020c5 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  8020ad:	c1 e8 0c             	shr    $0xc,%eax
  8020b0:	8d 14 40             	lea    (%eax,%eax,2),%edx
  8020b3:	c1 e2 02             	shl    $0x2,%edx
  8020b6:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  8020bb:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  8020c0:	0f b7 c0             	movzwl %ax,%eax
  8020c3:	eb 05                	jmp    8020ca <pageref+0x42>
  8020c5:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8020ca:	5d                   	pop    %ebp
  8020cb:	c3                   	ret    
  8020cc:	00 00                	add    %al,(%eax)
	...

008020d0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8020d0:	55                   	push   %ebp
  8020d1:	89 e5                	mov    %esp,%ebp
  8020d3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8020d6:	c7 44 24 04 58 35 80 	movl   $0x803558,0x4(%esp)
  8020dd:	00 
  8020de:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020e1:	89 04 24             	mov    %eax,(%esp)
  8020e4:	e8 31 e9 ff ff       	call   800a1a <strcpy>
	return 0;
}
  8020e9:	b8 00 00 00 00       	mov    $0x0,%eax
  8020ee:	c9                   	leave  
  8020ef:	c3                   	ret    

008020f0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8020f0:	55                   	push   %ebp
  8020f1:	89 e5                	mov    %esp,%ebp
  8020f3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8020f6:	8b 45 08             	mov    0x8(%ebp),%eax
  8020f9:	8b 40 0c             	mov    0xc(%eax),%eax
  8020fc:	89 04 24             	mov    %eax,(%esp)
  8020ff:	e8 9d 02 00 00       	call   8023a1 <nsipc_close>
}
  802104:	c9                   	leave  
  802105:	c3                   	ret    

00802106 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  802106:	55                   	push   %ebp
  802107:	89 e5                	mov    %esp,%ebp
  802109:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  80210c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  802113:	00 
  802114:	8b 45 10             	mov    0x10(%ebp),%eax
  802117:	89 44 24 08          	mov    %eax,0x8(%esp)
  80211b:	8b 45 0c             	mov    0xc(%ebp),%eax
  80211e:	89 44 24 04          	mov    %eax,0x4(%esp)
  802122:	8b 45 08             	mov    0x8(%ebp),%eax
  802125:	8b 40 0c             	mov    0xc(%eax),%eax
  802128:	89 04 24             	mov    %eax,(%esp)
  80212b:	e8 ad 02 00 00       	call   8023dd <nsipc_send>
}
  802130:	c9                   	leave  
  802131:	c3                   	ret    

00802132 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802132:	55                   	push   %ebp
  802133:	89 e5                	mov    %esp,%ebp
  802135:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802138:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80213f:	00 
  802140:	8b 45 10             	mov    0x10(%ebp),%eax
  802143:	89 44 24 08          	mov    %eax,0x8(%esp)
  802147:	8b 45 0c             	mov    0xc(%ebp),%eax
  80214a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80214e:	8b 45 08             	mov    0x8(%ebp),%eax
  802151:	8b 40 0c             	mov    0xc(%eax),%eax
  802154:	89 04 24             	mov    %eax,(%esp)
  802157:	e8 f4 02 00 00       	call   802450 <nsipc_recv>
}
  80215c:	c9                   	leave  
  80215d:	c3                   	ret    

0080215e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80215e:	55                   	push   %ebp
  80215f:	89 e5                	mov    %esp,%ebp
  802161:	56                   	push   %esi
  802162:	53                   	push   %ebx
  802163:	83 ec 20             	sub    $0x20,%esp
  802166:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802168:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80216b:	89 04 24             	mov    %eax,(%esp)
  80216e:	e8 28 f6 ff ff       	call   80179b <fd_alloc>
  802173:	89 c3                	mov    %eax,%ebx
  802175:	85 c0                	test   %eax,%eax
  802177:	78 21                	js     80219a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802179:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802180:	00 
  802181:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802184:	89 44 24 04          	mov    %eax,0x4(%esp)
  802188:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80218f:	e8 e2 ef ff ff       	call   801176 <sys_page_alloc>
  802194:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802196:	85 c0                	test   %eax,%eax
  802198:	79 0a                	jns    8021a4 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80219a:	89 34 24             	mov    %esi,(%esp)
  80219d:	e8 ff 01 00 00       	call   8023a1 <nsipc_close>
		return r;
  8021a2:	eb 28                	jmp    8021cc <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  8021a4:	8b 15 20 70 80 00    	mov    0x807020,%edx
  8021aa:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021ad:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  8021af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021b2:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  8021b9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021bc:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  8021bf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021c2:	89 04 24             	mov    %eax,(%esp)
  8021c5:	e8 a6 f5 ff ff       	call   801770 <fd2num>
  8021ca:	89 c3                	mov    %eax,%ebx
}
  8021cc:	89 d8                	mov    %ebx,%eax
  8021ce:	83 c4 20             	add    $0x20,%esp
  8021d1:	5b                   	pop    %ebx
  8021d2:	5e                   	pop    %esi
  8021d3:	5d                   	pop    %ebp
  8021d4:	c3                   	ret    

008021d5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8021d5:	55                   	push   %ebp
  8021d6:	89 e5                	mov    %esp,%ebp
  8021d8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8021db:	8b 45 10             	mov    0x10(%ebp),%eax
  8021de:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021e2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8021ec:	89 04 24             	mov    %eax,(%esp)
  8021ef:	e8 61 01 00 00       	call   802355 <nsipc_socket>
  8021f4:	85 c0                	test   %eax,%eax
  8021f6:	78 05                	js     8021fd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8021f8:	e8 61 ff ff ff       	call   80215e <alloc_sockfd>
}
  8021fd:	c9                   	leave  
  8021fe:	66 90                	xchg   %ax,%ax
  802200:	c3                   	ret    

00802201 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  802201:	55                   	push   %ebp
  802202:	89 e5                	mov    %esp,%ebp
  802204:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  802207:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80220a:	89 54 24 04          	mov    %edx,0x4(%esp)
  80220e:	89 04 24             	mov    %eax,(%esp)
  802211:	e8 f7 f5 ff ff       	call   80180d <fd_lookup>
  802216:	85 c0                	test   %eax,%eax
  802218:	78 15                	js     80222f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  80221a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80221d:	8b 0a                	mov    (%edx),%ecx
  80221f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802224:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  80222a:	75 03                	jne    80222f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  80222c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  80222f:	c9                   	leave  
  802230:	c3                   	ret    

00802231 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802231:	55                   	push   %ebp
  802232:	89 e5                	mov    %esp,%ebp
  802234:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802237:	8b 45 08             	mov    0x8(%ebp),%eax
  80223a:	e8 c2 ff ff ff       	call   802201 <fd2sockid>
  80223f:	85 c0                	test   %eax,%eax
  802241:	78 0f                	js     802252 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802243:	8b 55 0c             	mov    0xc(%ebp),%edx
  802246:	89 54 24 04          	mov    %edx,0x4(%esp)
  80224a:	89 04 24             	mov    %eax,(%esp)
  80224d:	e8 2d 01 00 00       	call   80237f <nsipc_listen>
}
  802252:	c9                   	leave  
  802253:	c3                   	ret    

00802254 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802254:	55                   	push   %ebp
  802255:	89 e5                	mov    %esp,%ebp
  802257:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80225a:	8b 45 08             	mov    0x8(%ebp),%eax
  80225d:	e8 9f ff ff ff       	call   802201 <fd2sockid>
  802262:	85 c0                	test   %eax,%eax
  802264:	78 16                	js     80227c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802266:	8b 55 10             	mov    0x10(%ebp),%edx
  802269:	89 54 24 08          	mov    %edx,0x8(%esp)
  80226d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802270:	89 54 24 04          	mov    %edx,0x4(%esp)
  802274:	89 04 24             	mov    %eax,(%esp)
  802277:	e8 54 02 00 00       	call   8024d0 <nsipc_connect>
}
  80227c:	c9                   	leave  
  80227d:	c3                   	ret    

0080227e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80227e:	55                   	push   %ebp
  80227f:	89 e5                	mov    %esp,%ebp
  802281:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802284:	8b 45 08             	mov    0x8(%ebp),%eax
  802287:	e8 75 ff ff ff       	call   802201 <fd2sockid>
  80228c:	85 c0                	test   %eax,%eax
  80228e:	78 0f                	js     80229f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802290:	8b 55 0c             	mov    0xc(%ebp),%edx
  802293:	89 54 24 04          	mov    %edx,0x4(%esp)
  802297:	89 04 24             	mov    %eax,(%esp)
  80229a:	e8 1c 01 00 00       	call   8023bb <nsipc_shutdown>
}
  80229f:	c9                   	leave  
  8022a0:	c3                   	ret    

008022a1 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8022a1:	55                   	push   %ebp
  8022a2:	89 e5                	mov    %esp,%ebp
  8022a4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8022a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8022aa:	e8 52 ff ff ff       	call   802201 <fd2sockid>
  8022af:	85 c0                	test   %eax,%eax
  8022b1:	78 16                	js     8022c9 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  8022b3:	8b 55 10             	mov    0x10(%ebp),%edx
  8022b6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022ba:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022bd:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022c1:	89 04 24             	mov    %eax,(%esp)
  8022c4:	e8 46 02 00 00       	call   80250f <nsipc_bind>
}
  8022c9:	c9                   	leave  
  8022ca:	c3                   	ret    

008022cb <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8022cb:	55                   	push   %ebp
  8022cc:	89 e5                	mov    %esp,%ebp
  8022ce:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8022d1:	8b 45 08             	mov    0x8(%ebp),%eax
  8022d4:	e8 28 ff ff ff       	call   802201 <fd2sockid>
  8022d9:	85 c0                	test   %eax,%eax
  8022db:	78 1f                	js     8022fc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8022dd:	8b 55 10             	mov    0x10(%ebp),%edx
  8022e0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022e4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022e7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022eb:	89 04 24             	mov    %eax,(%esp)
  8022ee:	e8 5b 02 00 00       	call   80254e <nsipc_accept>
  8022f3:	85 c0                	test   %eax,%eax
  8022f5:	78 05                	js     8022fc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8022f7:	e8 62 fe ff ff       	call   80215e <alloc_sockfd>
}
  8022fc:	c9                   	leave  
  8022fd:	8d 76 00             	lea    0x0(%esi),%esi
  802300:	c3                   	ret    
	...

00802310 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802310:	55                   	push   %ebp
  802311:	89 e5                	mov    %esp,%ebp
  802313:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802316:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80231c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802323:	00 
  802324:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80232b:	00 
  80232c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802330:	89 14 24             	mov    %edx,(%esp)
  802333:	e8 68 f3 ff ff       	call   8016a0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802338:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80233f:	00 
  802340:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802347:	00 
  802348:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80234b:	89 04 24             	mov    %eax,(%esp)
  80234e:	e8 bf f3 ff ff       	call   801712 <ipc_recv>
    return r;
}
  802353:	c9                   	leave  
  802354:	c3                   	ret    

00802355 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802355:	55                   	push   %ebp
  802356:	89 e5                	mov    %esp,%ebp
  802358:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80235b:	8b 45 08             	mov    0x8(%ebp),%eax
  80235e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802363:	8b 45 0c             	mov    0xc(%ebp),%eax
  802366:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80236b:	8b 45 10             	mov    0x10(%ebp),%eax
  80236e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802373:	b8 09 00 00 00       	mov    $0x9,%eax
  802378:	e8 93 ff ff ff       	call   802310 <nsipc>
}
  80237d:	c9                   	leave  
  80237e:	c3                   	ret    

0080237f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80237f:	55                   	push   %ebp
  802380:	89 e5                	mov    %esp,%ebp
  802382:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802385:	8b 45 08             	mov    0x8(%ebp),%eax
  802388:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80238d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802390:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802395:	b8 06 00 00 00       	mov    $0x6,%eax
  80239a:	e8 71 ff ff ff       	call   802310 <nsipc>
}
  80239f:	c9                   	leave  
  8023a0:	c3                   	ret    

008023a1 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  8023a1:	55                   	push   %ebp
  8023a2:	89 e5                	mov    %esp,%ebp
  8023a4:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  8023a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8023aa:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  8023af:	b8 04 00 00 00       	mov    $0x4,%eax
  8023b4:	e8 57 ff ff ff       	call   802310 <nsipc>
}
  8023b9:	c9                   	leave  
  8023ba:	c3                   	ret    

008023bb <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  8023bb:	55                   	push   %ebp
  8023bc:	89 e5                	mov    %esp,%ebp
  8023be:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  8023c1:	8b 45 08             	mov    0x8(%ebp),%eax
  8023c4:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  8023c9:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023cc:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8023d1:	b8 03 00 00 00       	mov    $0x3,%eax
  8023d6:	e8 35 ff ff ff       	call   802310 <nsipc>
}
  8023db:	c9                   	leave  
  8023dc:	c3                   	ret    

008023dd <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8023dd:	55                   	push   %ebp
  8023de:	89 e5                	mov    %esp,%ebp
  8023e0:	53                   	push   %ebx
  8023e1:	83 ec 14             	sub    $0x14,%esp
  8023e4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8023e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8023ea:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8023ef:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8023f5:	7e 24                	jle    80241b <nsipc_send+0x3e>
  8023f7:	c7 44 24 0c 64 35 80 	movl   $0x803564,0xc(%esp)
  8023fe:	00 
  8023ff:	c7 44 24 08 70 35 80 	movl   $0x803570,0x8(%esp)
  802406:	00 
  802407:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  80240e:	00 
  80240f:	c7 04 24 85 35 80 00 	movl   $0x803585,(%esp)
  802416:	e8 71 de ff ff       	call   80028c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80241b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80241f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802422:	89 44 24 04          	mov    %eax,0x4(%esp)
  802426:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80242d:	e8 a3 e7 ff ff       	call   800bd5 <memmove>
	nsipcbuf.send.req_size = size;
  802432:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802438:	8b 45 14             	mov    0x14(%ebp),%eax
  80243b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802440:	b8 08 00 00 00       	mov    $0x8,%eax
  802445:	e8 c6 fe ff ff       	call   802310 <nsipc>
}
  80244a:	83 c4 14             	add    $0x14,%esp
  80244d:	5b                   	pop    %ebx
  80244e:	5d                   	pop    %ebp
  80244f:	c3                   	ret    

00802450 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802450:	55                   	push   %ebp
  802451:	89 e5                	mov    %esp,%ebp
  802453:	56                   	push   %esi
  802454:	53                   	push   %ebx
  802455:	83 ec 10             	sub    $0x10,%esp
  802458:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80245b:	8b 45 08             	mov    0x8(%ebp),%eax
  80245e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802463:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802469:	8b 45 14             	mov    0x14(%ebp),%eax
  80246c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802471:	b8 07 00 00 00       	mov    $0x7,%eax
  802476:	e8 95 fe ff ff       	call   802310 <nsipc>
  80247b:	89 c3                	mov    %eax,%ebx
  80247d:	85 c0                	test   %eax,%eax
  80247f:	78 46                	js     8024c7 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802481:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802486:	7f 04                	jg     80248c <nsipc_recv+0x3c>
  802488:	39 c6                	cmp    %eax,%esi
  80248a:	7d 24                	jge    8024b0 <nsipc_recv+0x60>
  80248c:	c7 44 24 0c 91 35 80 	movl   $0x803591,0xc(%esp)
  802493:	00 
  802494:	c7 44 24 08 70 35 80 	movl   $0x803570,0x8(%esp)
  80249b:	00 
  80249c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  8024a3:	00 
  8024a4:	c7 04 24 85 35 80 00 	movl   $0x803585,(%esp)
  8024ab:	e8 dc dd ff ff       	call   80028c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  8024b0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024b4:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8024bb:	00 
  8024bc:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024bf:	89 04 24             	mov    %eax,(%esp)
  8024c2:	e8 0e e7 ff ff       	call   800bd5 <memmove>
	}

	return r;
}
  8024c7:	89 d8                	mov    %ebx,%eax
  8024c9:	83 c4 10             	add    $0x10,%esp
  8024cc:	5b                   	pop    %ebx
  8024cd:	5e                   	pop    %esi
  8024ce:	5d                   	pop    %ebp
  8024cf:	c3                   	ret    

008024d0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8024d0:	55                   	push   %ebp
  8024d1:	89 e5                	mov    %esp,%ebp
  8024d3:	53                   	push   %ebx
  8024d4:	83 ec 14             	sub    $0x14,%esp
  8024d7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8024da:	8b 45 08             	mov    0x8(%ebp),%eax
  8024dd:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8024e2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8024e6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024e9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024ed:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8024f4:	e8 dc e6 ff ff       	call   800bd5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8024f9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8024ff:	b8 05 00 00 00       	mov    $0x5,%eax
  802504:	e8 07 fe ff ff       	call   802310 <nsipc>
}
  802509:	83 c4 14             	add    $0x14,%esp
  80250c:	5b                   	pop    %ebx
  80250d:	5d                   	pop    %ebp
  80250e:	c3                   	ret    

0080250f <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  80250f:	55                   	push   %ebp
  802510:	89 e5                	mov    %esp,%ebp
  802512:	53                   	push   %ebx
  802513:	83 ec 14             	sub    $0x14,%esp
  802516:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802519:	8b 45 08             	mov    0x8(%ebp),%eax
  80251c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802521:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802525:	8b 45 0c             	mov    0xc(%ebp),%eax
  802528:	89 44 24 04          	mov    %eax,0x4(%esp)
  80252c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802533:	e8 9d e6 ff ff       	call   800bd5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802538:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80253e:	b8 02 00 00 00       	mov    $0x2,%eax
  802543:	e8 c8 fd ff ff       	call   802310 <nsipc>
}
  802548:	83 c4 14             	add    $0x14,%esp
  80254b:	5b                   	pop    %ebx
  80254c:	5d                   	pop    %ebp
  80254d:	c3                   	ret    

0080254e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80254e:	55                   	push   %ebp
  80254f:	89 e5                	mov    %esp,%ebp
  802551:	83 ec 18             	sub    $0x18,%esp
  802554:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802557:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80255a:	8b 45 08             	mov    0x8(%ebp),%eax
  80255d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802562:	b8 01 00 00 00       	mov    $0x1,%eax
  802567:	e8 a4 fd ff ff       	call   802310 <nsipc>
  80256c:	89 c3                	mov    %eax,%ebx
  80256e:	85 c0                	test   %eax,%eax
  802570:	78 25                	js     802597 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802572:	be 10 60 80 00       	mov    $0x806010,%esi
  802577:	8b 06                	mov    (%esi),%eax
  802579:	89 44 24 08          	mov    %eax,0x8(%esp)
  80257d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802584:	00 
  802585:	8b 45 0c             	mov    0xc(%ebp),%eax
  802588:	89 04 24             	mov    %eax,(%esp)
  80258b:	e8 45 e6 ff ff       	call   800bd5 <memmove>
		*addrlen = ret->ret_addrlen;
  802590:	8b 16                	mov    (%esi),%edx
  802592:	8b 45 10             	mov    0x10(%ebp),%eax
  802595:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802597:	89 d8                	mov    %ebx,%eax
  802599:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80259c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80259f:	89 ec                	mov    %ebp,%esp
  8025a1:	5d                   	pop    %ebp
  8025a2:	c3                   	ret    
	...

008025b0 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8025b0:	55                   	push   %ebp
  8025b1:	89 e5                	mov    %esp,%ebp
  8025b3:	83 ec 18             	sub    $0x18,%esp
  8025b6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8025b9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8025bc:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8025bf:	8b 45 08             	mov    0x8(%ebp),%eax
  8025c2:	89 04 24             	mov    %eax,(%esp)
  8025c5:	e8 b6 f1 ff ff       	call   801780 <fd2data>
  8025ca:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  8025cc:	c7 44 24 04 a6 35 80 	movl   $0x8035a6,0x4(%esp)
  8025d3:	00 
  8025d4:	89 34 24             	mov    %esi,(%esp)
  8025d7:	e8 3e e4 ff ff       	call   800a1a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8025dc:	8b 43 04             	mov    0x4(%ebx),%eax
  8025df:	2b 03                	sub    (%ebx),%eax
  8025e1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8025e7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8025ee:	00 00 00 
	stat->st_dev = &devpipe;
  8025f1:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  8025f8:	70 80 00 
	return 0;
}
  8025fb:	b8 00 00 00 00       	mov    $0x0,%eax
  802600:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802603:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802606:	89 ec                	mov    %ebp,%esp
  802608:	5d                   	pop    %ebp
  802609:	c3                   	ret    

0080260a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80260a:	55                   	push   %ebp
  80260b:	89 e5                	mov    %esp,%ebp
  80260d:	53                   	push   %ebx
  80260e:	83 ec 14             	sub    $0x14,%esp
  802611:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802614:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802618:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80261f:	e8 96 ea ff ff       	call   8010ba <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802624:	89 1c 24             	mov    %ebx,(%esp)
  802627:	e8 54 f1 ff ff       	call   801780 <fd2data>
  80262c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802630:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802637:	e8 7e ea ff ff       	call   8010ba <sys_page_unmap>
}
  80263c:	83 c4 14             	add    $0x14,%esp
  80263f:	5b                   	pop    %ebx
  802640:	5d                   	pop    %ebp
  802641:	c3                   	ret    

00802642 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802642:	55                   	push   %ebp
  802643:	89 e5                	mov    %esp,%ebp
  802645:	57                   	push   %edi
  802646:	56                   	push   %esi
  802647:	53                   	push   %ebx
  802648:	83 ec 2c             	sub    $0x2c,%esp
  80264b:	89 c7                	mov    %eax,%edi
  80264d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802650:	a1 74 70 80 00       	mov    0x807074,%eax
  802655:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802658:	89 3c 24             	mov    %edi,(%esp)
  80265b:	e8 28 fa ff ff       	call   802088 <pageref>
  802660:	89 c6                	mov    %eax,%esi
  802662:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802665:	89 04 24             	mov    %eax,(%esp)
  802668:	e8 1b fa ff ff       	call   802088 <pageref>
  80266d:	39 c6                	cmp    %eax,%esi
  80266f:	0f 94 c0             	sete   %al
  802672:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802675:	8b 15 74 70 80 00    	mov    0x807074,%edx
  80267b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80267e:	39 cb                	cmp    %ecx,%ebx
  802680:	75 08                	jne    80268a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802682:	83 c4 2c             	add    $0x2c,%esp
  802685:	5b                   	pop    %ebx
  802686:	5e                   	pop    %esi
  802687:	5f                   	pop    %edi
  802688:	5d                   	pop    %ebp
  802689:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80268a:	83 f8 01             	cmp    $0x1,%eax
  80268d:	75 c1                	jne    802650 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80268f:	8b 52 58             	mov    0x58(%edx),%edx
  802692:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802696:	89 54 24 08          	mov    %edx,0x8(%esp)
  80269a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80269e:	c7 04 24 ad 35 80 00 	movl   $0x8035ad,(%esp)
  8026a5:	e8 a7 dc ff ff       	call   800351 <cprintf>
  8026aa:	eb a4                	jmp    802650 <_pipeisclosed+0xe>

008026ac <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  8026ac:	55                   	push   %ebp
  8026ad:	89 e5                	mov    %esp,%ebp
  8026af:	57                   	push   %edi
  8026b0:	56                   	push   %esi
  8026b1:	53                   	push   %ebx
  8026b2:	83 ec 1c             	sub    $0x1c,%esp
  8026b5:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  8026b8:	89 34 24             	mov    %esi,(%esp)
  8026bb:	e8 c0 f0 ff ff       	call   801780 <fd2data>
  8026c0:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8026c2:	bf 00 00 00 00       	mov    $0x0,%edi
  8026c7:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8026cb:	75 54                	jne    802721 <devpipe_write+0x75>
  8026cd:	eb 60                	jmp    80272f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  8026cf:	89 da                	mov    %ebx,%edx
  8026d1:	89 f0                	mov    %esi,%eax
  8026d3:	e8 6a ff ff ff       	call   802642 <_pipeisclosed>
  8026d8:	85 c0                	test   %eax,%eax
  8026da:	74 07                	je     8026e3 <devpipe_write+0x37>
  8026dc:	b8 00 00 00 00       	mov    $0x0,%eax
  8026e1:	eb 53                	jmp    802736 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8026e3:	90                   	nop
  8026e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8026e8:	e8 e8 ea ff ff       	call   8011d5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8026ed:	8b 43 04             	mov    0x4(%ebx),%eax
  8026f0:	8b 13                	mov    (%ebx),%edx
  8026f2:	83 c2 20             	add    $0x20,%edx
  8026f5:	39 d0                	cmp    %edx,%eax
  8026f7:	73 d6                	jae    8026cf <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8026f9:	89 c2                	mov    %eax,%edx
  8026fb:	c1 fa 1f             	sar    $0x1f,%edx
  8026fe:	c1 ea 1b             	shr    $0x1b,%edx
  802701:	01 d0                	add    %edx,%eax
  802703:	83 e0 1f             	and    $0x1f,%eax
  802706:	29 d0                	sub    %edx,%eax
  802708:	89 c2                	mov    %eax,%edx
  80270a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80270d:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802711:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802715:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802719:	83 c7 01             	add    $0x1,%edi
  80271c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80271f:	76 13                	jbe    802734 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802721:	8b 43 04             	mov    0x4(%ebx),%eax
  802724:	8b 13                	mov    (%ebx),%edx
  802726:	83 c2 20             	add    $0x20,%edx
  802729:	39 d0                	cmp    %edx,%eax
  80272b:	73 a2                	jae    8026cf <devpipe_write+0x23>
  80272d:	eb ca                	jmp    8026f9 <devpipe_write+0x4d>
  80272f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802734:	89 f8                	mov    %edi,%eax
}
  802736:	83 c4 1c             	add    $0x1c,%esp
  802739:	5b                   	pop    %ebx
  80273a:	5e                   	pop    %esi
  80273b:	5f                   	pop    %edi
  80273c:	5d                   	pop    %ebp
  80273d:	c3                   	ret    

0080273e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80273e:	55                   	push   %ebp
  80273f:	89 e5                	mov    %esp,%ebp
  802741:	83 ec 28             	sub    $0x28,%esp
  802744:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802747:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80274a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80274d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802750:	89 3c 24             	mov    %edi,(%esp)
  802753:	e8 28 f0 ff ff       	call   801780 <fd2data>
  802758:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80275a:	be 00 00 00 00       	mov    $0x0,%esi
  80275f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802763:	75 4c                	jne    8027b1 <devpipe_read+0x73>
  802765:	eb 5b                	jmp    8027c2 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802767:	89 f0                	mov    %esi,%eax
  802769:	eb 5e                	jmp    8027c9 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80276b:	89 da                	mov    %ebx,%edx
  80276d:	89 f8                	mov    %edi,%eax
  80276f:	90                   	nop
  802770:	e8 cd fe ff ff       	call   802642 <_pipeisclosed>
  802775:	85 c0                	test   %eax,%eax
  802777:	74 07                	je     802780 <devpipe_read+0x42>
  802779:	b8 00 00 00 00       	mov    $0x0,%eax
  80277e:	eb 49                	jmp    8027c9 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802780:	e8 50 ea ff ff       	call   8011d5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802785:	8b 03                	mov    (%ebx),%eax
  802787:	3b 43 04             	cmp    0x4(%ebx),%eax
  80278a:	74 df                	je     80276b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80278c:	89 c2                	mov    %eax,%edx
  80278e:	c1 fa 1f             	sar    $0x1f,%edx
  802791:	c1 ea 1b             	shr    $0x1b,%edx
  802794:	01 d0                	add    %edx,%eax
  802796:	83 e0 1f             	and    $0x1f,%eax
  802799:	29 d0                	sub    %edx,%eax
  80279b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  8027a0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8027a3:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  8027a6:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8027a9:	83 c6 01             	add    $0x1,%esi
  8027ac:	39 75 10             	cmp    %esi,0x10(%ebp)
  8027af:	76 16                	jbe    8027c7 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  8027b1:	8b 03                	mov    (%ebx),%eax
  8027b3:	3b 43 04             	cmp    0x4(%ebx),%eax
  8027b6:	75 d4                	jne    80278c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  8027b8:	85 f6                	test   %esi,%esi
  8027ba:	75 ab                	jne    802767 <devpipe_read+0x29>
  8027bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8027c0:	eb a9                	jmp    80276b <devpipe_read+0x2d>
  8027c2:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  8027c7:	89 f0                	mov    %esi,%eax
}
  8027c9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8027cc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8027cf:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8027d2:	89 ec                	mov    %ebp,%esp
  8027d4:	5d                   	pop    %ebp
  8027d5:	c3                   	ret    

008027d6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8027d6:	55                   	push   %ebp
  8027d7:	89 e5                	mov    %esp,%ebp
  8027d9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8027dc:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8027df:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027e3:	8b 45 08             	mov    0x8(%ebp),%eax
  8027e6:	89 04 24             	mov    %eax,(%esp)
  8027e9:	e8 1f f0 ff ff       	call   80180d <fd_lookup>
  8027ee:	85 c0                	test   %eax,%eax
  8027f0:	78 15                	js     802807 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8027f2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027f5:	89 04 24             	mov    %eax,(%esp)
  8027f8:	e8 83 ef ff ff       	call   801780 <fd2data>
	return _pipeisclosed(fd, p);
  8027fd:	89 c2                	mov    %eax,%edx
  8027ff:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802802:	e8 3b fe ff ff       	call   802642 <_pipeisclosed>
}
  802807:	c9                   	leave  
  802808:	c3                   	ret    

00802809 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802809:	55                   	push   %ebp
  80280a:	89 e5                	mov    %esp,%ebp
  80280c:	83 ec 48             	sub    $0x48,%esp
  80280f:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802812:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802815:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802818:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80281b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80281e:	89 04 24             	mov    %eax,(%esp)
  802821:	e8 75 ef ff ff       	call   80179b <fd_alloc>
  802826:	89 c3                	mov    %eax,%ebx
  802828:	85 c0                	test   %eax,%eax
  80282a:	0f 88 42 01 00 00    	js     802972 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802830:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802837:	00 
  802838:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80283b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80283f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802846:	e8 2b e9 ff ff       	call   801176 <sys_page_alloc>
  80284b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80284d:	85 c0                	test   %eax,%eax
  80284f:	0f 88 1d 01 00 00    	js     802972 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802855:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802858:	89 04 24             	mov    %eax,(%esp)
  80285b:	e8 3b ef ff ff       	call   80179b <fd_alloc>
  802860:	89 c3                	mov    %eax,%ebx
  802862:	85 c0                	test   %eax,%eax
  802864:	0f 88 f5 00 00 00    	js     80295f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80286a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802871:	00 
  802872:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802875:	89 44 24 04          	mov    %eax,0x4(%esp)
  802879:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802880:	e8 f1 e8 ff ff       	call   801176 <sys_page_alloc>
  802885:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802887:	85 c0                	test   %eax,%eax
  802889:	0f 88 d0 00 00 00    	js     80295f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80288f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802892:	89 04 24             	mov    %eax,(%esp)
  802895:	e8 e6 ee ff ff       	call   801780 <fd2data>
  80289a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80289c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8028a3:	00 
  8028a4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028a8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028af:	e8 c2 e8 ff ff       	call   801176 <sys_page_alloc>
  8028b4:	89 c3                	mov    %eax,%ebx
  8028b6:	85 c0                	test   %eax,%eax
  8028b8:	0f 88 8e 00 00 00    	js     80294c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8028be:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028c1:	89 04 24             	mov    %eax,(%esp)
  8028c4:	e8 b7 ee ff ff       	call   801780 <fd2data>
  8028c9:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8028d0:	00 
  8028d1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8028d5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8028dc:	00 
  8028dd:	89 74 24 04          	mov    %esi,0x4(%esp)
  8028e1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028e8:	e8 2b e8 ff ff       	call   801118 <sys_page_map>
  8028ed:	89 c3                	mov    %eax,%ebx
  8028ef:	85 c0                	test   %eax,%eax
  8028f1:	78 49                	js     80293c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8028f3:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  8028f8:	8b 08                	mov    (%eax),%ecx
  8028fa:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8028fd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8028ff:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802902:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802909:	8b 10                	mov    (%eax),%edx
  80290b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80290e:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802910:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802913:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80291a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80291d:	89 04 24             	mov    %eax,(%esp)
  802920:	e8 4b ee ff ff       	call   801770 <fd2num>
  802925:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802927:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80292a:	89 04 24             	mov    %eax,(%esp)
  80292d:	e8 3e ee ff ff       	call   801770 <fd2num>
  802932:	89 47 04             	mov    %eax,0x4(%edi)
  802935:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80293a:	eb 36                	jmp    802972 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80293c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802940:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802947:	e8 6e e7 ff ff       	call   8010ba <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  80294c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80294f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802953:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80295a:	e8 5b e7 ff ff       	call   8010ba <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80295f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802962:	89 44 24 04          	mov    %eax,0x4(%esp)
  802966:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80296d:	e8 48 e7 ff ff       	call   8010ba <sys_page_unmap>
    err:
	return r;
}
  802972:	89 d8                	mov    %ebx,%eax
  802974:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802977:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80297a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80297d:	89 ec                	mov    %ebp,%esp
  80297f:	5d                   	pop    %ebp
  802980:	c3                   	ret    
	...

00802990 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802990:	55                   	push   %ebp
  802991:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802993:	b8 00 00 00 00       	mov    $0x0,%eax
  802998:	5d                   	pop    %ebp
  802999:	c3                   	ret    

0080299a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80299a:	55                   	push   %ebp
  80299b:	89 e5                	mov    %esp,%ebp
  80299d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  8029a0:	c7 44 24 04 c5 35 80 	movl   $0x8035c5,0x4(%esp)
  8029a7:	00 
  8029a8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029ab:	89 04 24             	mov    %eax,(%esp)
  8029ae:	e8 67 e0 ff ff       	call   800a1a <strcpy>
	return 0;
}
  8029b3:	b8 00 00 00 00       	mov    $0x0,%eax
  8029b8:	c9                   	leave  
  8029b9:	c3                   	ret    

008029ba <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  8029ba:	55                   	push   %ebp
  8029bb:	89 e5                	mov    %esp,%ebp
  8029bd:	57                   	push   %edi
  8029be:	56                   	push   %esi
  8029bf:	53                   	push   %ebx
  8029c0:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8029c6:	b8 00 00 00 00       	mov    $0x0,%eax
  8029cb:	be 00 00 00 00       	mov    $0x0,%esi
  8029d0:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8029d4:	74 41                	je     802a17 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  8029d6:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  8029dc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8029df:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  8029e1:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  8029e7:	ba 7f 00 00 00       	mov    $0x7f,%edx
  8029ec:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  8029ef:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8029f3:	03 45 0c             	add    0xc(%ebp),%eax
  8029f6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029fa:	89 3c 24             	mov    %edi,(%esp)
  8029fd:	e8 d3 e1 ff ff       	call   800bd5 <memmove>
		sys_cputs(buf, m);
  802a02:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802a06:	89 3c 24             	mov    %edi,(%esp)
  802a09:	e8 02 e4 ff ff       	call   800e10 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a0e:	01 de                	add    %ebx,%esi
  802a10:	89 f0                	mov    %esi,%eax
  802a12:	3b 75 10             	cmp    0x10(%ebp),%esi
  802a15:	72 c5                	jb     8029dc <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802a17:	89 f0                	mov    %esi,%eax
  802a19:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802a1f:	5b                   	pop    %ebx
  802a20:	5e                   	pop    %esi
  802a21:	5f                   	pop    %edi
  802a22:	5d                   	pop    %ebp
  802a23:	c3                   	ret    

00802a24 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802a24:	55                   	push   %ebp
  802a25:	89 e5                	mov    %esp,%ebp
  802a27:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802a2a:	8b 45 08             	mov    0x8(%ebp),%eax
  802a2d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802a30:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802a37:	00 
  802a38:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802a3b:	89 04 24             	mov    %eax,(%esp)
  802a3e:	e8 cd e3 ff ff       	call   800e10 <sys_cputs>
}
  802a43:	c9                   	leave  
  802a44:	c3                   	ret    

00802a45 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802a45:	55                   	push   %ebp
  802a46:	89 e5                	mov    %esp,%ebp
  802a48:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802a4b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a4f:	75 07                	jne    802a58 <devcons_read+0x13>
  802a51:	eb 2d                	jmp    802a80 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802a53:	e8 7d e7 ff ff       	call   8011d5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802a58:	90                   	nop
  802a59:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802a60:	e8 77 e3 ff ff       	call   800ddc <sys_cgetc>
  802a65:	85 c0                	test   %eax,%eax
  802a67:	74 ea                	je     802a53 <devcons_read+0xe>
  802a69:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802a6b:	85 c0                	test   %eax,%eax
  802a6d:	78 16                	js     802a85 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802a6f:	83 f8 04             	cmp    $0x4,%eax
  802a72:	74 0c                	je     802a80 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802a74:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a77:	88 10                	mov    %dl,(%eax)
  802a79:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802a7e:	eb 05                	jmp    802a85 <devcons_read+0x40>
  802a80:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802a85:	c9                   	leave  
  802a86:	c3                   	ret    

00802a87 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802a87:	55                   	push   %ebp
  802a88:	89 e5                	mov    %esp,%ebp
  802a8a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802a8d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802a90:	89 04 24             	mov    %eax,(%esp)
  802a93:	e8 03 ed ff ff       	call   80179b <fd_alloc>
  802a98:	85 c0                	test   %eax,%eax
  802a9a:	78 3f                	js     802adb <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802a9c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802aa3:	00 
  802aa4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802aa7:	89 44 24 04          	mov    %eax,0x4(%esp)
  802aab:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ab2:	e8 bf e6 ff ff       	call   801176 <sys_page_alloc>
  802ab7:	85 c0                	test   %eax,%eax
  802ab9:	78 20                	js     802adb <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802abb:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802ac1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ac4:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802ac6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ac9:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802ad0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ad3:	89 04 24             	mov    %eax,(%esp)
  802ad6:	e8 95 ec ff ff       	call   801770 <fd2num>
}
  802adb:	c9                   	leave  
  802adc:	c3                   	ret    

00802add <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802add:	55                   	push   %ebp
  802ade:	89 e5                	mov    %esp,%ebp
  802ae0:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802ae3:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802ae6:	89 44 24 04          	mov    %eax,0x4(%esp)
  802aea:	8b 45 08             	mov    0x8(%ebp),%eax
  802aed:	89 04 24             	mov    %eax,(%esp)
  802af0:	e8 18 ed ff ff       	call   80180d <fd_lookup>
  802af5:	85 c0                	test   %eax,%eax
  802af7:	78 11                	js     802b0a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802af9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802afc:	8b 00                	mov    (%eax),%eax
  802afe:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802b04:	0f 94 c0             	sete   %al
  802b07:	0f b6 c0             	movzbl %al,%eax
}
  802b0a:	c9                   	leave  
  802b0b:	c3                   	ret    

00802b0c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802b0c:	55                   	push   %ebp
  802b0d:	89 e5                	mov    %esp,%ebp
  802b0f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802b12:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802b19:	00 
  802b1a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802b1d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b21:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b28:	e8 46 ef ff ff       	call   801a73 <read>
	if (r < 0)
  802b2d:	85 c0                	test   %eax,%eax
  802b2f:	78 0f                	js     802b40 <getchar+0x34>
		return r;
	if (r < 1)
  802b31:	85 c0                	test   %eax,%eax
  802b33:	7f 07                	jg     802b3c <getchar+0x30>
  802b35:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802b3a:	eb 04                	jmp    802b40 <getchar+0x34>
		return -E_EOF;
	return c;
  802b3c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802b40:	c9                   	leave  
  802b41:	c3                   	ret    
	...

00802b44 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802b44:	55                   	push   %ebp
  802b45:	89 e5                	mov    %esp,%ebp
  802b47:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802b4a:	83 3d 7c 70 80 00 00 	cmpl   $0x0,0x80707c
  802b51:	75 55                	jne    802ba8 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802b53:	e8 b1 e6 ff ff       	call   801209 <sys_getenvid>
  802b58:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802b5f:	00 
  802b60:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802b67:	ee 
  802b68:	89 04 24             	mov    %eax,(%esp)
  802b6b:	e8 06 e6 ff ff       	call   801176 <sys_page_alloc>
  802b70:	85 c0                	test   %eax,%eax
  802b72:	74 1c                	je     802b90 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802b74:	c7 44 24 08 d4 35 80 	movl   $0x8035d4,0x8(%esp)
  802b7b:	00 
  802b7c:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802b83:	00 
  802b84:	c7 04 24 f8 35 80 00 	movl   $0x8035f8,(%esp)
  802b8b:	e8 fc d6 ff ff       	call   80028c <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802b90:	a1 74 70 80 00       	mov    0x807074,%eax
  802b95:	8b 40 4c             	mov    0x4c(%eax),%eax
  802b98:	c7 44 24 04 b4 2b 80 	movl   $0x802bb4,0x4(%esp)
  802b9f:	00 
  802ba0:	89 04 24             	mov    %eax,(%esp)
  802ba3:	e8 f8 e3 ff ff       	call   800fa0 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802ba8:	8b 45 08             	mov    0x8(%ebp),%eax
  802bab:	a3 7c 70 80 00       	mov    %eax,0x80707c
}
  802bb0:	c9                   	leave  
  802bb1:	c3                   	ret    
	...

00802bb4 <_pgfault_upcall>:
  802bb4:	54                   	push   %esp
  802bb5:	a1 7c 70 80 00       	mov    0x80707c,%eax
  802bba:	ff d0                	call   *%eax
  802bbc:	83 c4 04             	add    $0x4,%esp
  802bbf:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
  802bc4:	8b 44 24 30          	mov    0x30(%esp),%eax
  802bc8:	8b 5c 24 28          	mov    0x28(%esp),%ebx
  802bcc:	89 18                	mov    %ebx,(%eax)
  802bce:	83 c4 08             	add    $0x8,%esp
  802bd1:	61                   	popa   
  802bd2:	ff 74 24 04          	pushl  0x4(%esp)
  802bd6:	9d                   	popf   
  802bd7:	8b 64 24 08          	mov    0x8(%esp),%esp
  802bdb:	c3                   	ret    
  802bdc:	00 00                	add    %al,(%eax)
	...

00802be0 <__udivdi3>:
  802be0:	55                   	push   %ebp
  802be1:	89 e5                	mov    %esp,%ebp
  802be3:	57                   	push   %edi
  802be4:	56                   	push   %esi
  802be5:	83 ec 10             	sub    $0x10,%esp
  802be8:	8b 45 14             	mov    0x14(%ebp),%eax
  802beb:	8b 55 08             	mov    0x8(%ebp),%edx
  802bee:	8b 75 10             	mov    0x10(%ebp),%esi
  802bf1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802bf4:	85 c0                	test   %eax,%eax
  802bf6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802bf9:	75 35                	jne    802c30 <__udivdi3+0x50>
  802bfb:	39 fe                	cmp    %edi,%esi
  802bfd:	77 61                	ja     802c60 <__udivdi3+0x80>
  802bff:	85 f6                	test   %esi,%esi
  802c01:	75 0b                	jne    802c0e <__udivdi3+0x2e>
  802c03:	b8 01 00 00 00       	mov    $0x1,%eax
  802c08:	31 d2                	xor    %edx,%edx
  802c0a:	f7 f6                	div    %esi
  802c0c:	89 c6                	mov    %eax,%esi
  802c0e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802c11:	31 d2                	xor    %edx,%edx
  802c13:	89 f8                	mov    %edi,%eax
  802c15:	f7 f6                	div    %esi
  802c17:	89 c7                	mov    %eax,%edi
  802c19:	89 c8                	mov    %ecx,%eax
  802c1b:	f7 f6                	div    %esi
  802c1d:	89 c1                	mov    %eax,%ecx
  802c1f:	89 fa                	mov    %edi,%edx
  802c21:	89 c8                	mov    %ecx,%eax
  802c23:	83 c4 10             	add    $0x10,%esp
  802c26:	5e                   	pop    %esi
  802c27:	5f                   	pop    %edi
  802c28:	5d                   	pop    %ebp
  802c29:	c3                   	ret    
  802c2a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802c30:	39 f8                	cmp    %edi,%eax
  802c32:	77 1c                	ja     802c50 <__udivdi3+0x70>
  802c34:	0f bd d0             	bsr    %eax,%edx
  802c37:	83 f2 1f             	xor    $0x1f,%edx
  802c3a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802c3d:	75 39                	jne    802c78 <__udivdi3+0x98>
  802c3f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802c42:	0f 86 a0 00 00 00    	jbe    802ce8 <__udivdi3+0x108>
  802c48:	39 f8                	cmp    %edi,%eax
  802c4a:	0f 82 98 00 00 00    	jb     802ce8 <__udivdi3+0x108>
  802c50:	31 ff                	xor    %edi,%edi
  802c52:	31 c9                	xor    %ecx,%ecx
  802c54:	89 c8                	mov    %ecx,%eax
  802c56:	89 fa                	mov    %edi,%edx
  802c58:	83 c4 10             	add    $0x10,%esp
  802c5b:	5e                   	pop    %esi
  802c5c:	5f                   	pop    %edi
  802c5d:	5d                   	pop    %ebp
  802c5e:	c3                   	ret    
  802c5f:	90                   	nop
  802c60:	89 d1                	mov    %edx,%ecx
  802c62:	89 fa                	mov    %edi,%edx
  802c64:	89 c8                	mov    %ecx,%eax
  802c66:	31 ff                	xor    %edi,%edi
  802c68:	f7 f6                	div    %esi
  802c6a:	89 c1                	mov    %eax,%ecx
  802c6c:	89 fa                	mov    %edi,%edx
  802c6e:	89 c8                	mov    %ecx,%eax
  802c70:	83 c4 10             	add    $0x10,%esp
  802c73:	5e                   	pop    %esi
  802c74:	5f                   	pop    %edi
  802c75:	5d                   	pop    %ebp
  802c76:	c3                   	ret    
  802c77:	90                   	nop
  802c78:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802c7c:	89 f2                	mov    %esi,%edx
  802c7e:	d3 e0                	shl    %cl,%eax
  802c80:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802c83:	b8 20 00 00 00       	mov    $0x20,%eax
  802c88:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802c8b:	89 c1                	mov    %eax,%ecx
  802c8d:	d3 ea                	shr    %cl,%edx
  802c8f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802c93:	0b 55 ec             	or     -0x14(%ebp),%edx
  802c96:	d3 e6                	shl    %cl,%esi
  802c98:	89 c1                	mov    %eax,%ecx
  802c9a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802c9d:	89 fe                	mov    %edi,%esi
  802c9f:	d3 ee                	shr    %cl,%esi
  802ca1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ca5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ca8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802cab:	d3 e7                	shl    %cl,%edi
  802cad:	89 c1                	mov    %eax,%ecx
  802caf:	d3 ea                	shr    %cl,%edx
  802cb1:	09 d7                	or     %edx,%edi
  802cb3:	89 f2                	mov    %esi,%edx
  802cb5:	89 f8                	mov    %edi,%eax
  802cb7:	f7 75 ec             	divl   -0x14(%ebp)
  802cba:	89 d6                	mov    %edx,%esi
  802cbc:	89 c7                	mov    %eax,%edi
  802cbe:	f7 65 e8             	mull   -0x18(%ebp)
  802cc1:	39 d6                	cmp    %edx,%esi
  802cc3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802cc6:	72 30                	jb     802cf8 <__udivdi3+0x118>
  802cc8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802ccb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ccf:	d3 e2                	shl    %cl,%edx
  802cd1:	39 c2                	cmp    %eax,%edx
  802cd3:	73 05                	jae    802cda <__udivdi3+0xfa>
  802cd5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802cd8:	74 1e                	je     802cf8 <__udivdi3+0x118>
  802cda:	89 f9                	mov    %edi,%ecx
  802cdc:	31 ff                	xor    %edi,%edi
  802cde:	e9 71 ff ff ff       	jmp    802c54 <__udivdi3+0x74>
  802ce3:	90                   	nop
  802ce4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ce8:	31 ff                	xor    %edi,%edi
  802cea:	b9 01 00 00 00       	mov    $0x1,%ecx
  802cef:	e9 60 ff ff ff       	jmp    802c54 <__udivdi3+0x74>
  802cf4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802cf8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802cfb:	31 ff                	xor    %edi,%edi
  802cfd:	89 c8                	mov    %ecx,%eax
  802cff:	89 fa                	mov    %edi,%edx
  802d01:	83 c4 10             	add    $0x10,%esp
  802d04:	5e                   	pop    %esi
  802d05:	5f                   	pop    %edi
  802d06:	5d                   	pop    %ebp
  802d07:	c3                   	ret    
	...

00802d10 <__umoddi3>:
  802d10:	55                   	push   %ebp
  802d11:	89 e5                	mov    %esp,%ebp
  802d13:	57                   	push   %edi
  802d14:	56                   	push   %esi
  802d15:	83 ec 20             	sub    $0x20,%esp
  802d18:	8b 55 14             	mov    0x14(%ebp),%edx
  802d1b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802d1e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802d21:	8b 75 0c             	mov    0xc(%ebp),%esi
  802d24:	85 d2                	test   %edx,%edx
  802d26:	89 c8                	mov    %ecx,%eax
  802d28:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802d2b:	75 13                	jne    802d40 <__umoddi3+0x30>
  802d2d:	39 f7                	cmp    %esi,%edi
  802d2f:	76 3f                	jbe    802d70 <__umoddi3+0x60>
  802d31:	89 f2                	mov    %esi,%edx
  802d33:	f7 f7                	div    %edi
  802d35:	89 d0                	mov    %edx,%eax
  802d37:	31 d2                	xor    %edx,%edx
  802d39:	83 c4 20             	add    $0x20,%esp
  802d3c:	5e                   	pop    %esi
  802d3d:	5f                   	pop    %edi
  802d3e:	5d                   	pop    %ebp
  802d3f:	c3                   	ret    
  802d40:	39 f2                	cmp    %esi,%edx
  802d42:	77 4c                	ja     802d90 <__umoddi3+0x80>
  802d44:	0f bd ca             	bsr    %edx,%ecx
  802d47:	83 f1 1f             	xor    $0x1f,%ecx
  802d4a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802d4d:	75 51                	jne    802da0 <__umoddi3+0x90>
  802d4f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802d52:	0f 87 e0 00 00 00    	ja     802e38 <__umoddi3+0x128>
  802d58:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802d5b:	29 f8                	sub    %edi,%eax
  802d5d:	19 d6                	sbb    %edx,%esi
  802d5f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802d62:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802d65:	89 f2                	mov    %esi,%edx
  802d67:	83 c4 20             	add    $0x20,%esp
  802d6a:	5e                   	pop    %esi
  802d6b:	5f                   	pop    %edi
  802d6c:	5d                   	pop    %ebp
  802d6d:	c3                   	ret    
  802d6e:	66 90                	xchg   %ax,%ax
  802d70:	85 ff                	test   %edi,%edi
  802d72:	75 0b                	jne    802d7f <__umoddi3+0x6f>
  802d74:	b8 01 00 00 00       	mov    $0x1,%eax
  802d79:	31 d2                	xor    %edx,%edx
  802d7b:	f7 f7                	div    %edi
  802d7d:	89 c7                	mov    %eax,%edi
  802d7f:	89 f0                	mov    %esi,%eax
  802d81:	31 d2                	xor    %edx,%edx
  802d83:	f7 f7                	div    %edi
  802d85:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802d88:	f7 f7                	div    %edi
  802d8a:	eb a9                	jmp    802d35 <__umoddi3+0x25>
  802d8c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802d90:	89 c8                	mov    %ecx,%eax
  802d92:	89 f2                	mov    %esi,%edx
  802d94:	83 c4 20             	add    $0x20,%esp
  802d97:	5e                   	pop    %esi
  802d98:	5f                   	pop    %edi
  802d99:	5d                   	pop    %ebp
  802d9a:	c3                   	ret    
  802d9b:	90                   	nop
  802d9c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802da0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802da4:	d3 e2                	shl    %cl,%edx
  802da6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802da9:	ba 20 00 00 00       	mov    $0x20,%edx
  802dae:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802db1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802db4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802db8:	89 fa                	mov    %edi,%edx
  802dba:	d3 ea                	shr    %cl,%edx
  802dbc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802dc0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802dc3:	d3 e7                	shl    %cl,%edi
  802dc5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802dc9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802dcc:	89 f2                	mov    %esi,%edx
  802dce:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802dd1:	89 c7                	mov    %eax,%edi
  802dd3:	d3 ea                	shr    %cl,%edx
  802dd5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802dd9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802ddc:	89 c2                	mov    %eax,%edx
  802dde:	d3 e6                	shl    %cl,%esi
  802de0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802de4:	d3 ea                	shr    %cl,%edx
  802de6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802dea:	09 d6                	or     %edx,%esi
  802dec:	89 f0                	mov    %esi,%eax
  802dee:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802df1:	d3 e7                	shl    %cl,%edi
  802df3:	89 f2                	mov    %esi,%edx
  802df5:	f7 75 f4             	divl   -0xc(%ebp)
  802df8:	89 d6                	mov    %edx,%esi
  802dfa:	f7 65 e8             	mull   -0x18(%ebp)
  802dfd:	39 d6                	cmp    %edx,%esi
  802dff:	72 2b                	jb     802e2c <__umoddi3+0x11c>
  802e01:	39 c7                	cmp    %eax,%edi
  802e03:	72 23                	jb     802e28 <__umoddi3+0x118>
  802e05:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e09:	29 c7                	sub    %eax,%edi
  802e0b:	19 d6                	sbb    %edx,%esi
  802e0d:	89 f0                	mov    %esi,%eax
  802e0f:	89 f2                	mov    %esi,%edx
  802e11:	d3 ef                	shr    %cl,%edi
  802e13:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802e17:	d3 e0                	shl    %cl,%eax
  802e19:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e1d:	09 f8                	or     %edi,%eax
  802e1f:	d3 ea                	shr    %cl,%edx
  802e21:	83 c4 20             	add    $0x20,%esp
  802e24:	5e                   	pop    %esi
  802e25:	5f                   	pop    %edi
  802e26:	5d                   	pop    %ebp
  802e27:	c3                   	ret    
  802e28:	39 d6                	cmp    %edx,%esi
  802e2a:	75 d9                	jne    802e05 <__umoddi3+0xf5>
  802e2c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802e2f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802e32:	eb d1                	jmp    802e05 <__umoddi3+0xf5>
  802e34:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e38:	39 f2                	cmp    %esi,%edx
  802e3a:	0f 82 18 ff ff ff    	jb     802d58 <__umoddi3+0x48>
  802e40:	e9 1d ff ff ff       	jmp    802d62 <__umoddi3+0x52>
